diff options
author | Ryan Lortie <desrt@desrt.ca> | 2013-05-05 17:18:13 -0400 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2013-05-13 11:48:25 -0400 |
commit | 334695583195ac03f8942240468cf9a6c0045687 (patch) | |
tree | c4aa4f0f5c627055b2f2530d935278545c3a58ec | |
parent | 914099dce1bfaef71754c312b2711989fe30929d (diff) | |
download | gtk+-334695583195ac03f8942240468cf9a6c0045687.tar.gz |
tests: make GtkMenu test more flexible
We were using gtk_menu_item_get_label() from a testcase to determine the
label associated with a menu item. Future changes to GtkModelMenuItem
will cause this to stop working, so try a bit harder to find a label
inside of the item.
-rw-r--r-- | gtk/tests/gtkmenu.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/gtk/tests/gtkmenu.c b/gtk/tests/gtkmenu.c index 35bb434c3c..e2667ba135 100644 --- a/gtk/tests/gtkmenu.c +++ b/gtk/tests/gtkmenu.c @@ -216,6 +216,25 @@ random_menu_new (GRand *rand, static void assert_menu_equality (GtkContainer *container, GMenuModel *model); +static const gchar * +get_label (GtkMenuItem *item) +{ + GList *children = gtk_container_get_children (GTK_CONTAINER (item)); + const gchar *label = NULL; + + while (children) + { + if (GTK_IS_CONTAINER (children->data)) + children = g_list_concat (children, gtk_container_get_children (children->data)); + else if (GTK_IS_LABEL (children->data)) + label = gtk_label_get_text (children->data); + + children = g_list_delete_link (children, children); + } + + return label; +} + /* a bit complicated with the separators... * * with_separators are if subsections of this GMenuModel should have @@ -307,7 +326,7 @@ assert_section_equality (GSList **children, our_children = g_slist_remove (our_children, item); /* get_label() returns "" when it ought to return NULL */ - g_assert_cmpstr (gtk_menu_item_get_label (item), ==, label ? label : ""); + g_assert_cmpstr (get_label (item), ==, label ? label : ""); submenu_widget = gtk_menu_item_get_submenu (item); if (submenu) |