Back to index

dbus-test-runner  12.10.0
test-libdbustest.c
Go to the documentation of this file.
00001 
00002 #include <glib.h>
00003 #include <libdbustest/dbus-test.h>
00004 
00005 void
00006 test_env_var (void)
00007 {
00008        DbusTestService * service = dbus_test_service_new(NULL);
00009        g_assert(service != NULL);
00010 
00011        dbus_test_service_set_conf_file(service, SESSION_CONF);
00012 
00013        g_unsetenv("DBUS_SESSION_BUS_ADDRESS");
00014        dbus_test_service_start_tasks(service);
00015        g_assert(g_getenv("DBUS_SESSION_BUS_ADDRESS") != NULL);
00016 
00017        g_object_unref(service);
00018        return;
00019 }
00020 
00021 void
00022 test_task_start (void)
00023 {
00024        DbusTestService * service = dbus_test_service_new(NULL);
00025        g_assert(service != NULL);
00026 
00027        dbus_test_service_set_conf_file(service, SESSION_CONF);
00028 
00029        DbusTestTask * task = dbus_test_task_new();
00030        g_assert(task != NULL);
00031 
00032        dbus_test_service_add_task(service, task);
00033        dbus_test_service_start_tasks(service);
00034 
00035        g_assert(dbus_test_task_get_state(task) == DBUS_TEST_TASK_STATE_FINISHED);
00036 
00037        g_object_unref(task);
00038        g_object_unref(service);
00039 
00040        return;
00041 }
00042 
00043 void
00044 test_task_wait (void)
00045 {
00046        DbusTestService * service = dbus_test_service_new(NULL);
00047        g_assert(service != NULL);
00048 
00049        dbus_test_service_set_conf_file(service, SESSION_CONF);
00050 
00051        DbusTestTask * task = dbus_test_task_new();
00052        g_assert(task != NULL);
00053 
00054        dbus_test_task_set_wait_for(task, "org.test.name");
00055 
00056        dbus_test_service_add_task(service, task);
00057 
00058        DbusTestProcess * proc = dbus_test_process_new(GETNAME_PATH);
00059        g_assert(proc != NULL);
00060        g_assert(DBUS_TEST_IS_TASK(proc));
00061        dbus_test_process_append_param(proc, "org.test.name");
00062 
00063        dbus_test_service_add_task_with_priority(service, DBUS_TEST_TASK(proc), DBUS_TEST_SERVICE_PRIORITY_LAST);
00064 
00065        dbus_test_service_start_tasks(service);
00066 
00067        g_assert(dbus_test_task_get_state(task) == DBUS_TEST_TASK_STATE_FINISHED);
00068 
00069        g_object_unref(task);
00070        g_object_unref(service);
00071 
00072        return;
00073 }
00074 
00075 /* Build our test suite */
00076 void
00077 test_libdbustest_suite (void)
00078 {
00079        g_test_add_func ("/libdbustest/env_var",    test_env_var);
00080        g_test_add_func ("/libdbustest/task_start", test_task_start);
00081        g_test_add_func ("/libdbustest/task_wait",  test_task_wait);
00082 
00083        return;
00084 }
00085 
00086 int
00087 main (int argc, char ** argv)
00088 {
00089        g_type_init (); 
00090        g_test_init (&argc, &argv, NULL);
00091 
00092        test_libdbustest_suite();
00093 
00094        g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
00095 
00096        return g_test_run();
00097 }