Merge lp:~ted/libdbusmenu/testing-fixes into lp:libdbusmenu/0.6

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 393
Merge reported by: Charles Kerr
Merged at revision: not available
Proposed branch: lp:~ted/libdbusmenu/testing-fixes
Merge into: lp:libdbusmenu/0.6
Diff against target: 189 lines (+79/-26)
4 files modified
tests/Makefile.am (+1/-1)
tests/json-loader.c (+22/-4)
tests/test-json-client.c (+3/-20)
tools/dbusmenu-dumper.c (+53/-1)
To merge this branch: bzr merge lp:~ted/libdbusmenu/testing-fixes
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+99778@code.launchpad.net

This proposal supersedes a proposal from 2012-03-28.

Description of the change

Some testing fixes

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2012-02-23 05:55:58 +0000
+++ tests/Makefile.am 2012-03-28 16:18:31 +0000
@@ -208,7 +208,7 @@
208 @echo export UBUNTU_MENUPROXY="" >> $@208 @echo export UBUNTU_MENUPROXY="" >> $@
209 @echo export G_DEBUG=fatal_criticals >> $@209 @echo export G_DEBUG=fatal_criticals >> $@
210 @echo $(XVFB_RUN) >> $@210 @echo $(XVFB_RUN) >> $@
211 @echo $(DBUS_RUNNER) --task ./test-json-client --task-name Client --parameter $(top_builddir)/tools/dbusmenu-dumper --parameter test-json-01.output.json --ignore-return --task ./test-json-server --task-name Server --parameter $(srcdir)/test-json-01.json --ignore-return >> $@211 @echo $(DBUS_RUNNER) --task ./test-json-client --wait-for org.dbusmenu.test --task-name Client --parameter $(top_builddir)/tools/dbusmenu-dumper --parameter test-json-01.output.json --ignore-return --task ./test-json-server --task-name Server --parameter $(srcdir)/test-json-01.json --ignore-return >> $@
212 @echo diff $(srcdir)/test-json-01.json test-json-01.output.json \> /dev/null >> $@212 @echo diff $(srcdir)/test-json-01.json test-json-01.output.json \> /dev/null >> $@
213 @chmod +x $@213 @chmod +x $@
214214
215215
=== modified file 'tests/json-loader.c'
--- tests/json-loader.c 2012-01-27 02:20:23 +0000
+++ tests/json-loader.c 2012-03-28 16:18:31 +0000
@@ -24,6 +24,18 @@
24static GVariant * node2variant (JsonNode * node, const gchar * name);24static GVariant * node2variant (JsonNode * node, const gchar * name);
2525
26static void26static void
27array_byte_foreach (JsonArray * array, guint index, JsonNode * node, gpointer user_data)
28{
29 g_return_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_VALUE);
30 g_return_if_fail(json_node_get_value_type(node) == G_TYPE_INT || json_node_get_value_type(node) == G_TYPE_INT64);
31
32 GVariantBuilder * builder = (GVariantBuilder *)user_data;
33
34 g_variant_builder_add_value(builder, g_variant_new_byte(json_node_get_int(node)));
35 return;
36}
37
38static void
27array_foreach (JsonArray * array, guint index, JsonNode * node, gpointer user_data)39array_foreach (JsonArray * array, guint index, JsonNode * node, gpointer user_data)
28{40{
29 GVariantBuilder * builder = (GVariantBuilder *)user_data;41 GVariantBuilder * builder = (GVariantBuilder *)user_data;
@@ -79,11 +91,17 @@
79 }91 }
8092
81 if (JSON_NODE_TYPE(node) == JSON_NODE_ARRAY) {93 if (JSON_NODE_TYPE(node) == JSON_NODE_ARRAY) {
94 JsonArray * array = json_node_get_array(node);
82 GVariantBuilder builder;95 GVariantBuilder builder;
83 g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);96
8497 if (g_strcmp0(name, "icon-data") == 0) {
85 JsonArray * array = json_node_get_array(node);98 g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
86 json_array_foreach_element(array, array_foreach, &builder);99 json_array_foreach_element(array, array_byte_foreach, &builder);
100 } else {
101 g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
102 json_array_foreach_element(array, array_foreach, &builder);
103 }
104
87105
88 return g_variant_builder_end(&builder);106 return g_variant_builder_end(&builder);
89 }107 }
90108
=== modified file 'tests/test-json-client.c'
--- tests/test-json-client.c 2010-11-17 03:57:32 +0000
+++ tests/test-json-client.c 2012-03-28 16:18:31 +0000
@@ -27,14 +27,6 @@
27gboolean27gboolean
28timeout_func (gpointer user_data)28timeout_func (gpointer user_data)
29{29{
30 g_warning("Timeout without getting name");
31 g_main_loop_quit(mainloop);
32 return FALSE;
33}
34
35void
36name_appeared (GDBusConnection * connection, const gchar * name, const gchar * owner, gpointer user_data)
37{
38 char ** argv = (char **)user_data;30 char ** argv = (char **)user_data;
3931
40 g_usleep(500000);32 g_usleep(500000);
@@ -53,24 +45,15 @@
53 }45 }
5446
55 g_main_loop_quit(mainloop);47 g_main_loop_quit(mainloop);
56 return;48 return TRUE;
57}49}
5850
59int51int
60main (int argc, char ** argv)52main (int argc, char ** argv)
61{53{
62 g_type_init();54 g_type_init();
63 g_debug("Wait for friends");55
6456 g_timeout_add_seconds(2, timeout_func, argv);
65 g_bus_watch_name(G_BUS_TYPE_SESSION,
66 "org.dbusmenu.test",
67 G_BUS_NAME_WATCHER_FLAGS_NONE,
68 name_appeared,
69 NULL,
70 argv,
71 NULL);
72
73 g_timeout_add_seconds(2, timeout_func, NULL);
7457
75 mainloop = g_main_loop_new(NULL, FALSE);58 mainloop = g_main_loop_new(NULL, FALSE);
76 g_main_loop_run(mainloop);59 g_main_loop_run(mainloop);
7760
=== modified file 'tools/dbusmenu-dumper.c'
--- tools/dbusmenu-dumper.c 2011-02-16 15:59:17 +0000
+++ tools/dbusmenu-dumper.c 2012-03-28 16:18:31 +0000
@@ -28,6 +28,7 @@
2828
29#include <libdbusmenu-glib/client.h>29#include <libdbusmenu-glib/client.h>
30#include <libdbusmenu-glib/menuitem.h>30#include <libdbusmenu-glib/menuitem.h>
31#include <libdbusmenu-glib/menuitem-private.h>
3132
32#include <X11/Xlib.h>33#include <X11/Xlib.h>
3334
@@ -77,6 +78,7 @@
77 return;78 return;
78}79}
7980
81/* Prints the final JSON file recursively */
80static gboolean82static gboolean
81root_timeout (gpointer data)83root_timeout (gpointer data)
82{84{
@@ -90,6 +92,51 @@
90 return FALSE;92 return FALSE;
91}93}
9294
95/* Variables to deal with the number of items that we're watching to
96 realized */
97static int realized_count = 0;
98static DbusmenuMenuitem * root = NULL;
99
100/* Decrements the realization count, and if it gets to the end prints
101 out everything. */
102static void
103decrement_count (void)
104{
105 realized_count--;
106
107 if (realized_count == 0) {
108 root_timeout(root);
109 }
110
111 return;
112}
113
114/* Checks whether we need to watch a menu item, and recurses down to
115 it's children as well */
116static void
117check_realizations (DbusmenuMenuitem * item)
118{
119 g_return_if_fail(DBUSMENU_IS_MENUITEM(item));
120
121 if (!dbusmenu_menuitem_realized(item)) {
122 realized_count++;
123
124 g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_REALIZED, G_CALLBACK(decrement_count), NULL);
125 }
126
127 GList * children = dbusmenu_menuitem_get_children(item);
128 if (children != NULL) {
129 GList * child;
130 for (child = children; child != NULL; child = g_list_next(child)) {
131 check_realizations(DBUSMENU_MENUITEM(child->data));
132 }
133 }
134
135 return;
136}
137
138/* A setup for when we get our first root. We set up the basic realization
139 counter and set it to run. We'll print when it counts down */
93static void140static void
94new_root_cb (DbusmenuClient * client, DbusmenuMenuitem * newroot)141new_root_cb (DbusmenuClient * client, DbusmenuMenuitem * newroot)
95{142{
@@ -99,7 +146,12 @@
99 return;146 return;
100 }147 }
101148
102 g_timeout_add_seconds(2, root_timeout, newroot);149 root = newroot;
150 check_realizations(root);
151
152 realized_count++;
153 decrement_count();
154
103 return;155 return;
104}156}
105157

Subscribers

People subscribed via source and target branches

to all changes: