[glib] Improve GApplication test coverage



commit 0a1079d171439d89cd1c825d20c7d766ab3573b5
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 3 19:51:20 2012 -0400

    Improve GApplication test coverage

 gio/tests/basic-application.c |    1 +
 gio/tests/gapplication.c      |   45 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/gio/tests/basic-application.c b/gio/tests/basic-application.c
index c5f7b99..60c979d 100644
--- a/gio/tests/basic-application.c
+++ b/gio/tests/basic-application.c
@@ -60,6 +60,7 @@ main (int argc, char **argv)
   int status;
 
   app = g_application_new ("org.gtk.TestApplication",
+                           G_APPLICATION_SEND_ENVIRONMENT |
                            G_APPLICATION_HANDLES_OPEN |
                            (g_strcmp0 (argv[1], "./cmd") == 0 ?
                              G_APPLICATION_HANDLES_COMMAND_LINE
diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c
index 4dc239f..b7138cf 100644
--- a/gio/tests/gapplication.c
+++ b/gio/tests/gapplication.c
@@ -247,6 +247,10 @@ properties (void)
   g_assert (registered);
   g_assert (!remote);
 
+  g_object_set (app,
+                "inactivity-timeout", 1000,
+                NULL);
+
   g_application_quit (G_APPLICATION (app));
 
   g_object_unref (c);
@@ -301,6 +305,10 @@ nodbus_activate (GApplication *app)
 {
   nodbus_activated = TRUE;
   g_application_hold (app);
+
+  g_assert (g_application_get_dbus_connection (app) == NULL);
+  g_assert (g_application_get_dbus_object_path (app) == NULL);
+
   g_idle_add (release_app, app);
 }
 
@@ -310,8 +318,7 @@ test_nodbus (void)
   gchar *argv[] = { "./unimportant", NULL };
   GApplication *app;
 
-  app = g_application_new ("org.gtk.Unimportant",
-                           G_APPLICATION_FLAGS_NONE);
+  app = g_application_new ("org.gtk.Unimportant", G_APPLICATION_FLAGS_NONE);
   g_signal_connect (app, "activate", G_CALLBACK (nodbus_activate), NULL);
   g_application_run (app, 1, argv);
   g_object_unref (app);
@@ -319,6 +326,35 @@ test_nodbus (void)
   g_assert (nodbus_activated);
 }
 
+static gboolean noappid_activated;
+
+static void
+noappid_activate (GApplication *app)
+{
+  noappid_activated = TRUE;
+  g_application_hold (app);
+
+  g_assert (g_application_get_flags (app) & G_APPLICATION_NON_UNIQUE);
+
+  g_idle_add (release_app, app);
+}
+
+/* test that no appid -> non-unique */
+static void
+test_noappid (void)
+{
+  gchar *argv[] = { "./unimportant", NULL };
+  GApplication *app;
+
+  app = g_application_new (NULL, G_APPLICATION_FLAGS_NONE);
+  g_signal_connect (app, "activate", G_CALLBACK (noappid_activate), NULL);
+  g_application_run (app, 1, argv);
+  g_object_unref (app);
+
+  g_assert (noappid_activated);
+}
+
+
 static gboolean
 quit_app (gpointer user_data)
 {
@@ -333,6 +369,10 @@ quit_activate (GApplication *app)
 {
   quit_activated = TRUE;
   g_application_hold (app);
+
+  g_assert (g_application_get_dbus_connection (app) != NULL);
+  g_assert (g_application_get_dbus_object_path (app) != NULL);
+
   g_idle_add (quit_app, app);
 }
 
@@ -417,6 +457,7 @@ main (int argc, char **argv)
 
   g_test_add_func ("/gapplication/no-dbus", test_nodbus);
   g_test_add_func ("/gapplication/basic", basic);
+  g_test_add_func ("/gapplication/no-appid", test_noappid);
 /*  g_test_add_func ("/gapplication/non-unique", test_nonunique); */
   g_test_add_func ("/gapplication/properties", properties);
   g_test_add_func ("/gapplication/app-id", appid);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]