[glib] Add app lauch environment test



commit 448be24cf38e90c0ba415cb37cbc0bae09666593
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 16 00:08:42 2011 -0400

    Add app lauch environment test

 gio/tests/appinfo.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/appinfo.c b/gio/tests/appinfo.c
index d9221d7..d0a8207 100644
--- a/gio/tests/appinfo.c
+++ b/gio/tests/appinfo.c
@@ -243,6 +243,36 @@ test_associations (void)
   g_object_unref (appinfo);
 }
 
+static void
+test_environment (void)
+{
+  GAppLaunchContext *ctx;
+  gchar **env;
+
+  ctx = g_app_launch_context_new ();
+  g_app_launch_context_setenv (ctx, "FOO", "bar");
+  g_app_launch_context_setenv (ctx, "BLA", "bla");
+
+  env = g_app_launch_context_get_environment (ctx);
+
+  g_assert_cmpstr (g_environ_getenv (env, "FOO"), ==, "bar");
+  g_assert_cmpstr (g_environ_getenv (env, "BLA"), ==, "bla");
+
+  g_strfreev (env);
+
+  g_app_launch_context_setenv (ctx, "FOO", "baz");
+  g_app_launch_context_unsetenv (ctx, "BLA");
+
+  env = g_app_launch_context_get_environment (ctx);
+
+  g_assert_cmpstr (g_environ_getenv (env, "FOO"), ==, "baz");
+  g_assert (g_environ_getenv (env, "BLA") == NULL);
+
+  g_strfreev (env);
+
+  g_object_unref (ctx);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -257,6 +287,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/appinfo/launch-context", test_launch_context);
   g_test_add_func ("/appinfo/tryexec", test_tryexec);
   g_test_add_func ("/appinfo/associations", test_associations);
+  g_test_add_func ("/appinfo/environment", test_environment);
 
   return g_test_run ();
 }



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