mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 20:35:49 +01:00
gapplication: test setting and binding busy state
https://bugzilla.gnome.org/show_bug.cgi?id=744756
This commit is contained in:
parent
b4ef6d957f
commit
2b27382596
@ -749,6 +749,65 @@ test_help (void)
|
|||||||
g_test_trap_assert_stdout ("*Application options*");
|
g_test_trap_assert_stdout ("*Application options*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_busy (void)
|
||||||
|
{
|
||||||
|
GApplication *app;
|
||||||
|
|
||||||
|
/* use GSimpleAction to bind to the busy state, because it's easy to
|
||||||
|
* create and has an easily modifiable boolean property */
|
||||||
|
GSimpleAction *action1;
|
||||||
|
GSimpleAction *action2;
|
||||||
|
|
||||||
|
session_bus_up ();
|
||||||
|
|
||||||
|
app = g_application_new ("org.gtk.TestApplication", G_APPLICATION_NON_UNIQUE);
|
||||||
|
g_assert (g_application_register (app, NULL, NULL));
|
||||||
|
|
||||||
|
g_assert (!g_application_get_is_busy (app));
|
||||||
|
g_application_mark_busy (app);
|
||||||
|
g_assert (g_application_get_is_busy (app));
|
||||||
|
g_application_unmark_busy (app);
|
||||||
|
g_assert (!g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
action1 = g_simple_action_new ("action", NULL);
|
||||||
|
g_application_bind_busy_property (app, action1, "enabled");
|
||||||
|
g_assert (g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
g_simple_action_set_enabled (action1, FALSE);
|
||||||
|
g_assert (!g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
g_application_mark_busy (app);
|
||||||
|
g_assert (g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
action2 = g_simple_action_new ("action", NULL);
|
||||||
|
g_application_bind_busy_property (app, action2, "enabled");
|
||||||
|
g_assert (g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
g_application_unmark_busy (app);
|
||||||
|
g_assert (g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
g_object_unref (action2);
|
||||||
|
g_assert (!g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
g_simple_action_set_enabled (action1, TRUE);
|
||||||
|
g_assert (g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
g_application_mark_busy (app);
|
||||||
|
g_assert (g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
g_application_unbind_busy_property (app, action1, "enabled");
|
||||||
|
g_assert (g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
g_application_unmark_busy (app);
|
||||||
|
g_assert (!g_application_get_is_busy (app));
|
||||||
|
|
||||||
|
g_object_unref (action1);
|
||||||
|
g_object_unref (app);
|
||||||
|
|
||||||
|
session_bus_down ();
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -769,6 +828,7 @@ main (int argc, char **argv)
|
|||||||
/* g_test_add_func ("/gapplication/remote-command-line", test_remote_command_line); */
|
/* g_test_add_func ("/gapplication/remote-command-line", test_remote_command_line); */
|
||||||
g_test_add_func ("/gapplication/resource-path", test_resource_path);
|
g_test_add_func ("/gapplication/resource-path", test_resource_path);
|
||||||
g_test_add_func ("/gapplication/test-help", test_help);
|
g_test_add_func ("/gapplication/test-help", test_help);
|
||||||
|
g_test_add_func ("/gapplication/test-busy", test_busy);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user