[glib/wip/menus-rebase3] Add some tests for links
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/menus-rebase3] Add some tests for links
- Date: Mon, 28 Nov 2011 04:29:30 +0000 (UTC)
commit 7131b5817a4fba980c177bca18db43d9d8f063b2
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Nov 27 18:12:52 2011 -0500
Add some tests for links
gio/tests/gmenumodel.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gmenumodel.c b/gio/tests/gmenumodel.c
index 2df3ebc..52d71d9 100644
--- a/gio/tests/gmenumodel.c
+++ b/gio/tests/gmenumodel.c
@@ -762,6 +762,72 @@ test_attributes (void)
g_object_unref (menu);
}
+static void
+test_links (void)
+{
+ GMenu *menu;
+ GMenuModel *m;
+ GMenuModel *x;
+ GMenuItem *item;
+
+ m = G_MENU_MODEL (g_menu_new ());
+ g_menu_append (G_MENU (m), "test", NULL);
+
+ menu = g_menu_new ();
+
+ item = g_menu_item_new ("test1", NULL);
+ g_menu_item_set_link (item, "section", m);
+ g_menu_append_item (menu, item);
+
+ item = g_menu_item_new ("test2", NULL);
+ g_menu_item_set_link (item, "submenu", m);
+ g_menu_append_item (menu, item);
+
+ item = g_menu_item_new ("test3", NULL);
+ g_menu_item_set_link (item, "wallet", m);
+ g_menu_append_item (menu, item);
+
+ item = g_menu_item_new ("test4", NULL);
+ g_menu_item_set_link (item, "purse", m);
+ g_menu_item_set_link (item, "purse", NULL);
+ g_menu_append_item (menu, item);
+
+ g_assert_cmpint (g_menu_model_get_n_items (G_MENU_MODEL (menu)), ==, 4);
+
+ x = g_menu_model_get_item_link (G_MENU_MODEL (menu), 0, "section");
+ g_assert (x == m);
+ g_object_unref (x);
+
+ x = g_menu_model_get_item_link (G_MENU_MODEL (menu), 1, "submenu");
+ g_assert (x == m);
+ g_object_unref (x);
+
+ x = g_menu_model_get_item_link (G_MENU_MODEL (menu), 2, "wallet");
+ g_assert (x == m);
+ g_object_unref (x);
+
+ x = g_menu_model_get_item_link (G_MENU_MODEL (menu), 3, "purse");
+ g_assert (x == NULL);
+
+ g_object_unref (m);
+ g_object_unref (menu);
+}
+
+static void
+test_mutable (void)
+{
+ GMenu *menu;
+
+ menu = g_menu_new ();
+ g_menu_append (menu, "test", "test");
+
+ g_assert (g_menu_model_is_mutable (G_MENU_MODEL (menu)));
+ g_menu_freeze (menu);
+ g_assert (!g_menu_model_is_mutable (G_MENU_MODEL (menu)));
+
+ g_object_unref (menu);
+}
+
/* Epilogue {{{1 */
int
main (int argc, char **argv)
@@ -775,6 +841,8 @@ main (int argc, char **argv)
g_test_add_func ("/gmenu/bus/roundtrip", test_dbus_roundtrip);
g_test_add_func ("/gmenu/markup/roundtrip", test_markup_roundtrip);
g_test_add_func ("/gmenu/attributes", test_attributes);
+ g_test_add_func ("/gmenu/links", test_links);
+ g_test_add_func ("/gmenu/mutable", test_mutable);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]