3 #include "gdbus-sessionbus.h"
5 /* Markup printing {{{1 */
7 /* This used to be part of GLib, but it was removed before the stable
8 * release because it wasn't generally useful. We want it here, though.
11 indent_string (GString *string,
15 g_string_append_c (string, ' ');
19 g_menu_markup_print_string (GString *string,
24 gboolean need_nl = FALSE;
27 if G_UNLIKELY (string == NULL)
28 string = g_string_new (NULL);
30 n = g_menu_model_get_n_items (model);
32 for (i = 0; i < n; i++)
34 GMenuAttributeIter *attr_iter;
35 GMenuLinkIter *link_iter;
39 attr_iter = g_menu_model_iterate_item_attributes (model, i);
40 link_iter = g_menu_model_iterate_item_links (model, i);
41 contents = g_string_new (NULL);
42 attrs = g_string_new (NULL);
44 while (g_menu_attribute_iter_next (attr_iter))
46 const char *name = g_menu_attribute_iter_get_name (attr_iter);
47 GVariant *value = g_menu_attribute_iter_get_value (attr_iter);
49 if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
52 str = g_markup_printf_escaped (" %s='%s'", name, g_variant_get_string (value, NULL));
53 g_string_append (attrs, str);
63 printed = g_variant_print (value, TRUE);
64 type = g_variant_type_peek_string (g_variant_get_type (value));
65 str = g_markup_printf_escaped ("<attribute name='%s' type='%s'>%s</attribute>\n", name, type, printed);
66 indent_string (contents, indent + tabstop);
67 g_string_append (contents, str);
72 g_variant_unref (value);
74 g_object_unref (attr_iter);
76 while (g_menu_link_iter_next (link_iter))
78 const gchar *name = g_menu_link_iter_get_name (link_iter);
79 GMenuModel *menu = g_menu_link_iter_get_value (link_iter);
83 g_string_append_c (contents, '\n');
85 str = g_markup_printf_escaped ("<link name='%s'>\n", name);
86 indent_string (contents, indent + tabstop);
87 g_string_append (contents, str);
90 g_menu_markup_print_string (contents, menu, indent + 2 * tabstop, tabstop);
92 indent_string (contents, indent + tabstop);
93 g_string_append (contents, "</link>\n");
94 g_object_unref (menu);
96 g_object_unref (link_iter);
100 indent_string (string, indent);
101 g_string_append_printf (string, "<item%s>\n", attrs->str);
102 g_string_append (string, contents->str);
103 indent_string (string, indent);
104 g_string_append (string, "</item>\n");
111 g_string_append_c (string, '\n');
113 indent_string (string, indent);
114 g_string_append_printf (string, "<item%s/>\n", attrs->str);
118 g_string_free (contents, TRUE);
119 g_string_free (attrs, TRUE);
127 /* This utility struct is used by both the RandomMenu and MirrorMenu
128 * class implementations below.
131 GHashTable *attributes;
136 test_item_new (GHashTable *attributes,
141 item = g_slice_new (TestItem);
142 item->attributes = g_hash_table_ref (attributes);
143 item->links = g_hash_table_ref (links);
149 test_item_free (gpointer data)
151 TestItem *item = data;
153 g_hash_table_unref (item->attributes);
154 g_hash_table_unref (item->links);
156 g_slice_free (TestItem, item);
159 /* RandomMenu {{{1 */
164 GMenuModel parent_instance;
170 typedef GMenuModelClass RandomMenuClass;
172 static GType random_menu_get_type (void);
173 G_DEFINE_TYPE (RandomMenu, random_menu, G_TYPE_MENU_MODEL);
176 random_menu_is_mutable (GMenuModel *model)
182 random_menu_get_n_items (GMenuModel *model)
184 RandomMenu *menu = (RandomMenu *) model;
186 return g_sequence_get_length (menu->items);
190 random_menu_get_item_attributes (GMenuModel *model,
194 RandomMenu *menu = (RandomMenu *) model;
197 item = g_sequence_get (g_sequence_get_iter_at_pos (menu->items, position));
198 *table = g_hash_table_ref (item->attributes);
202 random_menu_get_item_links (GMenuModel *model,
206 RandomMenu *menu = (RandomMenu *) model;
209 item = g_sequence_get (g_sequence_get_iter_at_pos (menu->items, position));
210 *table = g_hash_table_ref (item->links);
214 random_menu_finalize (GObject *object)
216 RandomMenu *menu = (RandomMenu *) object;
218 g_sequence_free (menu->items);
220 G_OBJECT_CLASS (random_menu_parent_class)
225 random_menu_init (RandomMenu *menu)
230 random_menu_class_init (GMenuModelClass *class)
232 GObjectClass *object_class = G_OBJECT_CLASS (class);
234 class->is_mutable = random_menu_is_mutable;
235 class->get_n_items = random_menu_get_n_items;
236 class->get_item_attributes = random_menu_get_item_attributes;
237 class->get_item_links = random_menu_get_item_links;
239 object_class->finalize = random_menu_finalize;
242 static RandomMenu * random_menu_new (GRand *rand, gint order);
245 random_menu_change (RandomMenu *menu,
248 gint position, removes, adds;
249 GSequenceIter *point;
253 n_items = g_sequence_get_length (menu->items);
257 position = g_rand_int_range (rand, 0, n_items + 1);
258 removes = g_rand_int_range (rand, 0, n_items - position + 1);
259 adds = g_rand_int_range (rand, 0, MAX_ITEMS - (n_items - removes) + 1);
261 while (removes == 0 && adds == 0);
263 point = g_sequence_get_iter_at_pos (menu->items, position + removes);
267 GSequenceIter *start;
269 start = g_sequence_get_iter_at_pos (menu->items, position);
270 g_sequence_remove_range (start, point);
273 for (i = 0; i < adds; i++)
277 GHashTable *attributes;
279 attributes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
280 links = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_object_unref);
282 if (menu->order > 0 && g_rand_boolean (rand))
285 const gchar *subtype;
287 child = random_menu_new (rand, menu->order - 1);
289 if (g_rand_boolean (rand))
291 subtype = G_MENU_LINK_SECTION;
292 /* label some section headers */
293 if (g_rand_boolean (rand))
300 /* label all submenus */
301 subtype = G_MENU_LINK_SUBMENU;
305 g_hash_table_insert (links, g_strdup (subtype), child);
308 /* label all terminals */
312 g_hash_table_insert (attributes, g_strdup ("label"), g_variant_ref_sink (g_variant_new_string (label)));
314 g_sequence_insert_before (point, test_item_new (attributes, links));
315 g_hash_table_unref (links);
316 g_hash_table_unref (attributes);
319 g_menu_model_items_changed (G_MENU_MODEL (menu), position, removes, adds);
323 random_menu_new (GRand *rand,
328 menu = g_object_new (random_menu_get_type (), NULL);
329 menu->items = g_sequence_new (test_item_free);
332 random_menu_change (menu, rand);
337 /* MirrorMenu {{{1 */
339 GMenuModel parent_instance;
341 GMenuModel *clone_of;
346 typedef GMenuModelClass MirrorMenuClass;
348 static GType mirror_menu_get_type (void);
349 G_DEFINE_TYPE (MirrorMenu, mirror_menu, G_TYPE_MENU_MODEL);
352 mirror_menu_is_mutable (GMenuModel *model)
354 MirrorMenu *menu = (MirrorMenu *) model;
356 return menu->handler_id != 0;
360 mirror_menu_get_n_items (GMenuModel *model)
362 MirrorMenu *menu = (MirrorMenu *) model;
364 return g_sequence_get_length (menu->items);
368 mirror_menu_get_item_attributes (GMenuModel *model,
372 MirrorMenu *menu = (MirrorMenu *) model;
375 item = g_sequence_get (g_sequence_get_iter_at_pos (menu->items, position));
376 *table = g_hash_table_ref (item->attributes);
380 mirror_menu_get_item_links (GMenuModel *model,
384 MirrorMenu *menu = (MirrorMenu *) model;
387 item = g_sequence_get (g_sequence_get_iter_at_pos (menu->items, position));
388 *table = g_hash_table_ref (item->links);
392 mirror_menu_finalize (GObject *object)
394 MirrorMenu *menu = (MirrorMenu *) object;
396 if (menu->handler_id)
397 g_signal_handler_disconnect (menu->clone_of, menu->handler_id);
399 g_sequence_free (menu->items);
400 g_object_unref (menu->clone_of);
402 G_OBJECT_CLASS (mirror_menu_parent_class)
407 mirror_menu_init (MirrorMenu *menu)
412 mirror_menu_class_init (GMenuModelClass *class)
414 GObjectClass *object_class = G_OBJECT_CLASS (class);
416 class->is_mutable = mirror_menu_is_mutable;
417 class->get_n_items = mirror_menu_get_n_items;
418 class->get_item_attributes = mirror_menu_get_item_attributes;
419 class->get_item_links = mirror_menu_get_item_links;
421 object_class->finalize = mirror_menu_finalize;
424 static MirrorMenu * mirror_menu_new (GMenuModel *clone_of);
427 mirror_menu_changed (GMenuModel *model,
433 MirrorMenu *menu = user_data;
434 GSequenceIter *point;
437 g_assert (model == menu->clone_of);
439 point = g_sequence_get_iter_at_pos (menu->items, position + removed);
443 GSequenceIter *start;
445 start = g_sequence_get_iter_at_pos (menu->items, position);
446 g_sequence_remove_range (start, point);
449 for (i = position; i < position + added; i++)
451 GMenuAttributeIter *attr_iter;
452 GMenuLinkIter *link_iter;
454 GHashTable *attributes;
459 attributes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
460 links = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_object_unref);
462 attr_iter = g_menu_model_iterate_item_attributes (model, i);
463 while (g_menu_attribute_iter_get_next (attr_iter, &name, &value))
465 g_hash_table_insert (attributes, g_strdup (name), value);
467 g_object_unref (attr_iter);
469 link_iter = g_menu_model_iterate_item_links (model, i);
470 while (g_menu_link_iter_get_next (link_iter, &name, &child))
472 g_hash_table_insert (links, g_strdup (name), mirror_menu_new (child));
473 g_object_unref (child);
475 g_object_unref (link_iter);
477 g_sequence_insert_before (point, test_item_new (attributes, links));
478 g_hash_table_unref (attributes);
479 g_hash_table_unref (links);
482 g_menu_model_items_changed (G_MENU_MODEL (menu), position, removed, added);
486 mirror_menu_new (GMenuModel *clone_of)
490 menu = g_object_new (mirror_menu_get_type (), NULL);
491 menu->items = g_sequence_new (test_item_free);
492 menu->clone_of = g_object_ref (clone_of);
494 if (g_menu_model_is_mutable (clone_of))
495 menu->handler_id = g_signal_connect (clone_of, "items-changed", G_CALLBACK (mirror_menu_changed), menu);
496 mirror_menu_changed (clone_of, 0, 0, g_menu_model_get_n_items (clone_of), menu);
501 /* check_menus_equal(), assert_menus_equal() {{{1 */
503 check_menus_equal (GMenuModel *a,
506 gboolean equal = TRUE;
510 a_n = g_menu_model_get_n_items (a);
511 b_n = g_menu_model_get_n_items (b);
516 for (i = 0; i < a_n; i++)
518 GMenuAttributeIter *attr_iter;
519 GVariant *a_value, *b_value;
520 GMenuLinkIter *link_iter;
521 GMenuModel *a_menu, *b_menu;
524 attr_iter = g_menu_model_iterate_item_attributes (a, i);
525 while (g_menu_attribute_iter_get_next (attr_iter, &name, &a_value))
527 b_value = g_menu_model_get_item_attribute_value (b, i, name, NULL);
528 equal &= b_value && g_variant_equal (a_value, b_value);
530 g_variant_unref (b_value);
531 g_variant_unref (a_value);
533 g_object_unref (attr_iter);
535 attr_iter = g_menu_model_iterate_item_attributes (b, i);
536 while (g_menu_attribute_iter_get_next (attr_iter, &name, &b_value))
538 a_value = g_menu_model_get_item_attribute_value (a, i, name, NULL);
539 equal &= a_value && g_variant_equal (a_value, b_value);
541 g_variant_unref (a_value);
542 g_variant_unref (b_value);
544 g_object_unref (attr_iter);
546 link_iter = g_menu_model_iterate_item_links (a, i);
547 while (g_menu_link_iter_get_next (link_iter, &name, &a_menu))
549 b_menu = g_menu_model_get_item_link (b, i, name);
550 equal &= b_menu && check_menus_equal (a_menu, b_menu);
552 g_object_unref (b_menu);
553 g_object_unref (a_menu);
555 g_object_unref (link_iter);
557 link_iter = g_menu_model_iterate_item_links (b, i);
558 while (g_menu_link_iter_get_next (link_iter, &name, &b_menu))
560 a_menu = g_menu_model_get_item_link (a, i, name);
561 equal &= a_menu && check_menus_equal (a_menu, b_menu);
563 g_object_unref (a_menu);
564 g_object_unref (b_menu);
566 g_object_unref (link_iter);
573 assert_menus_equal (GMenuModel *a,
576 if (!check_menus_equal (a, b))
580 string = g_string_new ("\n <a>\n");
581 g_menu_markup_print_string (string, G_MENU_MODEL (a), 4, 2);
582 g_string_append (string, " </a>\n\n-------------\n <b>\n");
583 g_menu_markup_print_string (string, G_MENU_MODEL (b), 4, 2);
584 g_string_append (string, " </b>\n");
585 g_error ("%s", string->str);
589 /* Test cases {{{1 */
593 GRand *randa, *randb;
597 seed = g_test_rand_int ();
599 randa = g_rand_new_with_seed (seed);
600 randb = g_rand_new_with_seed (seed);
602 for (i = 0; i < 500; i++)
606 a = random_menu_new (randa, TOP_ORDER);
607 b = random_menu_new (randb, TOP_ORDER);
608 assert_menus_equal (G_MENU_MODEL (a), G_MENU_MODEL (b));
615 for (i = 0; i < 500;)
619 a = random_menu_new (randa, TOP_ORDER);
620 b = random_menu_new (randb, TOP_ORDER);
621 if (check_menus_equal (G_MENU_MODEL (a), G_MENU_MODEL (b)))
623 /* by chance, they may really be equal. double check. */
626 as = g_menu_markup_print_string (NULL, G_MENU_MODEL (a), 4, 2);
627 bs = g_menu_markup_print_string (NULL, G_MENU_MODEL (b), 4, 2);
628 g_assert_cmpstr (as->str, ==, bs->str);
629 g_string_free (bs, TRUE);
630 g_string_free (as, TRUE);
632 /* we're here because randa and randb just generated equal
633 * menus. they may do it again, so throw away randb and make
637 randb = g_rand_new_with_seed (g_rand_int (randa));
640 /* make sure we get enough unequals (ie: no GRand failure) */
659 rand = g_rand_new_with_seed (g_test_rand_int ());
660 random = random_menu_new (rand, TOP_ORDER);
661 mirror = mirror_menu_new (G_MENU_MODEL (random));
663 for (i = 0; i < 500; i++)
665 assert_menus_equal (G_MENU_MODEL (random), G_MENU_MODEL (mirror));
666 random_menu_change (random, rand);
669 g_object_unref (mirror);
670 g_object_unref (random);
675 struct roundtrip_state
678 MirrorMenu *proxy_mirror;
679 GDBusMenuModel *proxy;
687 roundtrip_step (gpointer data)
689 struct roundtrip_state *state = data;
691 if (check_menus_equal (G_MENU_MODEL (state->random), G_MENU_MODEL (state->proxy)) &&
692 check_menus_equal (G_MENU_MODEL (state->random), G_MENU_MODEL (state->proxy_mirror)))
697 if (state->success < 100)
698 random_menu_change (state->random, state->rand);
700 g_main_loop_quit (state->loop);
702 else if (state->count == 100)
704 assert_menus_equal (G_MENU_MODEL (state->random), G_MENU_MODEL (state->proxy));
705 g_assert_not_reached ();
710 return G_SOURCE_CONTINUE;
714 test_dbus_roundtrip (void)
716 struct roundtrip_state state;
717 GDBusConnection *bus;
721 bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
723 state.rand = g_rand_new_with_seed (g_test_rand_int ());
725 state.random = random_menu_new (state.rand, 2);
726 export_id = g_dbus_connection_export_menu_model (bus, "/", G_MENU_MODEL (state.random), NULL);
727 state.proxy = g_dbus_menu_model_get (bus, g_dbus_connection_get_unique_name (bus), "/");
728 state.proxy_mirror = mirror_menu_new (G_MENU_MODEL (state.proxy));
732 id = g_timeout_add (10, roundtrip_step, &state);
734 state.loop = g_main_loop_new (NULL, FALSE);
735 g_main_loop_run (state.loop);
737 g_main_loop_unref (state.loop);
738 g_source_remove (id);
739 g_object_unref (state.proxy);
740 g_dbus_connection_unexport_menu_model (bus, export_id);
741 g_object_unref (state.random);
742 g_object_unref (state.proxy_mirror);
743 g_rand_free (state.rand);
744 g_object_unref (bus);
747 static gint items_changed_count;
750 items_changed (GMenuModel *model,
756 items_changed_count++;
760 stop_loop (gpointer data)
762 GMainLoop *loop = data;
764 g_main_loop_quit (loop);
766 return G_SOURCE_REMOVE;
770 test_dbus_subscriptions (void)
772 GDBusConnection *bus;
774 GDBusMenuModel *proxy;
776 GError *error = NULL;
779 loop = g_main_loop_new (NULL, FALSE);
781 bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
783 menu = g_menu_new ();
785 export_id = g_dbus_connection_export_menu_model (bus, "/", G_MENU_MODEL (menu), &error);
786 g_assert_no_error (error);
788 proxy = g_dbus_menu_model_get (bus, g_dbus_connection_get_unique_name (bus), "/");
789 items_changed_count = 0;
790 g_signal_connect (proxy, "items-changed",
791 G_CALLBACK (items_changed), NULL);
793 g_menu_append (menu, "item1", NULL);
794 g_menu_append (menu, "item2", NULL);
795 g_menu_append (menu, "item3", NULL);
797 g_assert_cmpint (items_changed_count, ==, 0);
799 g_timeout_add (100, stop_loop, loop);
800 g_main_loop_run (loop);
802 g_menu_model_get_n_items (G_MENU_MODEL (proxy));
804 g_timeout_add (100, stop_loop, loop);
805 g_main_loop_run (loop);
807 g_assert_cmpint (items_changed_count, ==, 1);
808 g_assert_cmpint (g_menu_model_get_n_items (G_MENU_MODEL (proxy)), ==, 3);
810 g_timeout_add (100, stop_loop, loop);
811 g_main_loop_run (loop);
813 g_menu_append (menu, "item4", NULL);
814 g_menu_append (menu, "item5", NULL);
815 g_menu_append (menu, "item6", NULL);
816 g_menu_remove (menu, 0);
817 g_menu_remove (menu, 0);
819 g_timeout_add (200, stop_loop, loop);
820 g_main_loop_run (loop);
822 g_assert_cmpint (items_changed_count, ==, 6);
824 g_assert_cmpint (g_menu_model_get_n_items (G_MENU_MODEL (proxy)), ==, 4);
825 g_object_unref (proxy);
827 g_timeout_add (100, stop_loop, loop);
828 g_main_loop_run (loop);
830 g_menu_remove (menu, 0);
831 g_menu_remove (menu, 0);
833 g_timeout_add (100, stop_loop, loop);
834 g_main_loop_run (loop);
836 g_assert_cmpint (items_changed_count, ==, 6);
838 g_dbus_connection_unexport_menu_model (bus, export_id);
839 g_object_unref (menu);
841 g_main_loop_unref (loop);
842 g_object_unref (bus);
846 do_modify (gpointer data)
848 RandomMenu *menu = data;
852 rand = g_rand_new_with_seed (g_test_rand_int ());
854 for (i = 0; i < 10000; i++)
856 random_menu_change (menu, rand);
863 do_export (gpointer data)
865 GMenuModel *menu = data;
867 GDBusConnection *bus;
869 GError *error = NULL;
872 bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
873 path = g_strdup_printf ("/%p", data);
875 for (i = 0; i < 10000; i++)
877 id = g_dbus_connection_export_menu_model (bus, path, menu, &error);
878 g_assert_no_error (error);
879 g_dbus_connection_unexport_menu_model (bus, id);
880 while (g_main_context_iteration (NULL, FALSE));
885 g_object_unref (bus);
891 test_dbus_threaded (void)
893 RandomMenu *menu[10];
898 for (i = 0; i < 10; i++)
900 menu[i] = random_menu_new (g_rand_new_with_seed (g_test_rand_int ()), 2);
901 call[i] = g_thread_new ("call", do_modify, menu[i]);
902 export[i] = g_thread_new ("export", do_export, menu[i]);
905 for (i = 0; i < 10; i++)
907 g_thread_join (call[i]);
908 g_thread_join (export[i]);
911 for (i = 0; i < 10; i++)
912 g_object_unref (menu[i]);
916 test_attributes (void)
922 menu = g_menu_new ();
924 item = g_menu_item_new ("test", NULL);
925 g_menu_item_set_attribute_value (item, "boolean", g_variant_new_boolean (FALSE));
926 g_menu_item_set_attribute_value (item, "string", g_variant_new_string ("bla"));
927 g_menu_item_set_attribute_value (item, "double", g_variant_new_double (1.5));
928 v = g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
929 g_menu_item_set_attribute_value (item, "complex", v);
930 g_menu_item_set_attribute_value (item, "test-123", g_variant_new_string ("test-123"));
932 g_menu_append_item (menu, item);
934 g_assert_cmpint (g_menu_model_get_n_items (G_MENU_MODEL (menu)), ==, 1);
936 v = g_menu_model_get_item_attribute_value (G_MENU_MODEL (menu), 0, "boolean", NULL);
937 g_assert (g_variant_is_of_type (v, G_VARIANT_TYPE_BOOLEAN));
940 v = g_menu_model_get_item_attribute_value (G_MENU_MODEL (menu), 0, "string", NULL);
941 g_assert (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING));
944 v = g_menu_model_get_item_attribute_value (G_MENU_MODEL (menu), 0, "double", NULL);
945 g_assert (g_variant_is_of_type (v, G_VARIANT_TYPE_DOUBLE));
948 v = g_menu_model_get_item_attribute_value (G_MENU_MODEL (menu), 0, "complex", NULL);
949 g_assert (g_variant_is_of_type (v, G_VARIANT_TYPE("a(si)")));
952 g_object_unref (menu);
963 m = G_MENU_MODEL (g_menu_new ());
964 g_menu_append (G_MENU (m), "test", NULL);
966 menu = g_menu_new ();
968 item = g_menu_item_new ("test1", NULL);
969 g_menu_item_set_link (item, "section", m);
970 g_menu_append_item (menu, item);
972 item = g_menu_item_new ("test2", NULL);
973 g_menu_item_set_link (item, "submenu", m);
974 g_menu_append_item (menu, item);
976 item = g_menu_item_new ("test3", NULL);
977 g_menu_item_set_link (item, "wallet", m);
978 g_menu_append_item (menu, item);
980 item = g_menu_item_new ("test4", NULL);
981 g_menu_item_set_link (item, "purse", m);
982 g_menu_item_set_link (item, "purse", NULL);
983 g_menu_append_item (menu, item);
985 g_assert_cmpint (g_menu_model_get_n_items (G_MENU_MODEL (menu)), ==, 4);
987 x = g_menu_model_get_item_link (G_MENU_MODEL (menu), 0, "section");
991 x = g_menu_model_get_item_link (G_MENU_MODEL (menu), 1, "submenu");
995 x = g_menu_model_get_item_link (G_MENU_MODEL (menu), 2, "wallet");
999 x = g_menu_model_get_item_link (G_MENU_MODEL (menu), 3, "purse");
1000 g_assert (x == NULL);
1003 g_object_unref (menu);
1011 menu = g_menu_new ();
1012 g_menu_append (menu, "test", "test");
1014 g_assert (g_menu_model_is_mutable (G_MENU_MODEL (menu)));
1015 g_menu_freeze (menu);
1016 g_assert (!g_menu_model_is_mutable (G_MENU_MODEL (menu)));
1018 g_object_unref (menu);
1023 main (int argc, char **argv)
1027 g_test_init (&argc, &argv, NULL);
1032 g_test_add_func ("/gmenu/equality", test_equality);
1033 g_test_add_func ("/gmenu/random", test_random);
1034 g_test_add_func ("/gmenu/dbus/roundtrip", test_dbus_roundtrip);
1035 g_test_add_func ("/gmenu/dbus/subscriptions", test_dbus_subscriptions);
1036 g_test_add_func ("/gmenu/dbus/threaded", test_dbus_threaded);
1037 g_test_add_func ("/gmenu/attributes", test_attributes);
1038 g_test_add_func ("/gmenu/links", test_links);
1039 g_test_add_func ("/gmenu/mutable", test_mutable);
1041 ret = g_test_run ();
1043 session_bus_down ();
1047 /* vim:set foldmethod=marker: */