[glib] Add a test for ids on submenu and section elements
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add a test for ids on submenu and section elements
- Date: Sun, 25 Dec 2011 04:01:41 +0000 (UTC)
commit f077127d0169df135d078827c1c51742c3a71901
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 24 22:59:10 2011 -0500
Add a test for ids on submenu and section elements
The test checks that menus which are created via
<submenu id=...> or <section id=...> end up in the objects
hash table.
gio/tests/gmenumodel.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gmenumodel.c b/gio/tests/gmenumodel.c
index 8a0cb2c..4253f99 100644
--- a/gio/tests/gmenumodel.c
+++ b/gio/tests/gmenumodel.c
@@ -932,6 +932,46 @@ test_markup_objects (void)
g_hash_table_unref (objects);
}
+const gchar menu_data2[] =
+ "<menu>"
+ " <section>"
+ " <item label='Redo' action='redo'/>"
+ " </section>"
+ " <section></section>\n"
+ " <section label='Copy & Paste'>"
+ " <item label='Cut' action='cut'/>"
+ " </section>"
+ " <section id='section1'>"
+ " <item label='Bold' action='bold'/>"
+ " <submenu label='Language' id='submenu1'>"
+ " <section id='section2'>"
+ " <item label='Urdu' action='lang' target='urdu'/>"
+ " </section>"
+ " </submenu>"
+ " </section>"
+ "</menu>";
+static void
+test_markup_ids (void)
+{
+ GMenuModel *a, *b;
+ GHashTable *objects;
+ GError *error = NULL;
+
+ objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+ a = parse_menu_string (menu_data2, objects, &error);
+ g_assert_no_error (error);
+ g_assert (G_IS_MENU_MODEL (a));
+ g_assert_cmpint (g_hash_table_size (objects), ==, 3);
+ b = g_hash_table_lookup (objects, "section1");
+ g_assert (G_IS_MENU_MODEL (b));
+ b = g_hash_table_lookup (objects, "section2");
+ g_assert (G_IS_MENU_MODEL (b));
+ b = g_hash_table_lookup (objects, "submenu1");
+ g_assert (G_IS_MENU_MODEL (b));
+ g_object_unref (a);
+ g_hash_table_unref (objects);
+}
+
static void
test_attributes (void)
{
@@ -1119,6 +1159,7 @@ main (int argc, char **argv)
g_test_add_func ("/gmenu/dbus/threaded", test_dbus_threaded);
g_test_add_func ("/gmenu/markup/roundtrip", test_markup_roundtrip);
g_test_add_func ("/gmenu/markup/objects", test_markup_objects);
+ g_test_add_func ("/gmenu/markup/ids", test_markup_ids);
g_test_add_func ("/gmenu/attributes", test_attributes);
g_test_add_func ("/gmenu/links", test_links);
g_test_add_func ("/gmenu/mutable", test_mutable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]