Back to index

dbus-test-runner  12.10.0
Classes | Defines | Typedefs | Enumerations | Functions
task.h File Reference
#include <glib.h>
#include <glib-object.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DbusTestTaskClass
struct  _DbusTestTask

Defines

#define DBUS_TEST_TASK_SIGNAL_STATE_CHANGED   "state-changed"
#define DBUS_TEST_TYPE_TASK   (dbus_test_task_get_type ())
#define DBUS_TEST_TASK(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUS_TEST_TYPE_TASK, DbusTestTask))
#define DBUS_TEST_TASK_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TEST_TYPE_TASK, DbusTestTaskClass))
#define DBUS_TEST_IS_TASK(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUS_TEST_TYPE_TASK))
#define DBUS_TEST_IS_TASK_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TEST_TYPE_TASK))
#define DBUS_TEST_TASK_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TEST_TYPE_TASK, DbusTestTaskClass))

Typedefs

typedef struct _DbusTestTask
typedef struct _DbusTestTaskClass
typedef struct _DbusTestTaskPrivate

Enumerations

enum  DbusTestTaskState { DBUS_TEST_TASK_STATE_INIT, DBUS_TEST_TASK_STATE_WAITING, DBUS_TEST_TASK_STATE_RUNNING, DBUS_TEST_TASK_STATE_FINISHED }
enum  DbusTestTaskReturn { DBUS_TEST_TASK_RETURN_NORMAL, DBUS_TEST_TASK_RETURN_IGNORE, DBUS_TEST_TASK_RETURN_INVERT }

Functions

GType dbus_test_task_get_type (void)
DbusTestTask * dbus_test_task_new (void)
void dbus_test_task_set_name (DbusTestTask *task, const gchar *name)
void dbus_test_task_set_name_spacing (DbusTestTask *task, glong chars)
void dbus_test_task_set_wait_for (DbusTestTask *task, const gchar *dbus_name)
void dbus_test_task_set_return (DbusTestTask *task, DbusTestTaskReturn ret)
void dbus_test_task_print (DbusTestTask *task, const gchar *message)
DbusTestTaskState dbus_test_task_get_state (DbusTestTask *task)
DbusTestTaskReturn dbus_test_task_get_return (DbusTestTask *task)
const gchar * dbus_test_task_get_name (DbusTestTask *task)
const gchar * dbus_test_task_get_wait_for (DbusTestTask *task)
void dbus_test_task_run (DbusTestTask *task)
gboolean dbus_test_task_passed (DbusTestTask *task)

Class Documentation

struct _DbusTestTask

Definition at line 72 of file task.h.

Class Members
GObject parent
DbusTestTaskPrivate * priv

Define Documentation

#define DBUS_TEST_IS_TASK (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUS_TEST_TYPE_TASK))

Definition at line 37 of file task.h.

#define DBUS_TEST_IS_TASK_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TEST_TYPE_TASK))

Definition at line 38 of file task.h.

#define DBUS_TEST_TASK (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUS_TEST_TYPE_TASK, DbusTestTask))

Definition at line 35 of file task.h.

#define DBUS_TEST_TASK_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TEST_TYPE_TASK, DbusTestTaskClass))

Definition at line 36 of file task.h.

#define DBUS_TEST_TASK_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TEST_TYPE_TASK, DbusTestTaskClass))

Definition at line 39 of file task.h.

#define DBUS_TEST_TASK_SIGNAL_STATE_CHANGED   "state-changed"

Definition at line 32 of file task.h.

Definition at line 34 of file task.h.


Typedef Documentation

typedef struct _DbusTestTask

Definition at line 41 of file task.h.

typedef struct _DbusTestTaskClass

Definition at line 42 of file task.h.

typedef struct _DbusTestTaskPrivate

Definition at line 43 of file task.h.


Enumeration Type Documentation

Enumerator:
DBUS_TEST_TASK_RETURN_NORMAL 
DBUS_TEST_TASK_RETURN_IGNORE 
DBUS_TEST_TASK_RETURN_INVERT 

Definition at line 53 of file task.h.

Enumerator:
DBUS_TEST_TASK_STATE_INIT 
DBUS_TEST_TASK_STATE_WAITING 
DBUS_TEST_TASK_STATE_RUNNING 
DBUS_TEST_TASK_STATE_FINISHED 

Definition at line 45 of file task.h.


Function Documentation

const gchar* dbus_test_task_get_name ( DbusTestTask *  task)

Definition at line 335 of file task.c.

{
       g_return_val_if_fail(DBUS_TEST_IS_TASK(task), NULL);

       return task->priv->name;
}

Here is the caller graph for this function:

Definition at line 253 of file task.c.

{
       g_return_val_if_fail(DBUS_TEST_IS_TASK(task), DBUS_TEST_TASK_RETURN_IGNORE);

       return task->priv->return_type;
}

Here is the caller graph for this function:

DbusTestTaskState dbus_test_task_get_state ( DbusTestTask *  task)

Definition at line 232 of file task.c.

{
       g_return_val_if_fail(DBUS_TEST_IS_TASK(task), DBUS_TEST_TASK_STATE_FINISHED);

       if (task->priv->wait_task != 0) {
              return DBUS_TEST_TASK_STATE_WAITING;
       }

       DbusTestTaskClass * klass = DBUS_TEST_TASK_GET_CLASS(task);
       if (klass->get_state != NULL) {
              return klass->get_state(task);
       }

       if (task->priv->been_run) {
              return DBUS_TEST_TASK_STATE_FINISHED;
       } else {
              return DBUS_TEST_TASK_STATE_INIT;
       }
}

Here is the caller graph for this function:

GType dbus_test_task_get_type ( void  )
const gchar* dbus_test_task_get_wait_for ( DbusTestTask *  task)

Definition at line 343 of file task.c.

{
       g_return_val_if_fail(DBUS_TEST_IS_TASK(task), NULL);

       return task->priv->wait_for;
}

Here is the caller graph for this function:

DbusTestTask* dbus_test_task_new ( void  )

Definition at line 134 of file task.c.

{
       DbusTestTask * task = g_object_new(DBUS_TEST_TYPE_TASK,
                                          NULL);

       return task;
}

Here is the caller graph for this function:

gboolean dbus_test_task_passed ( DbusTestTask *  task)

Definition at line 311 of file task.c.

{
       g_return_val_if_fail(DBUS_TEST_IS_TASK(task), FALSE);

       /* If we don't care, we always pass */
       if (task->priv->return_type == DBUS_TEST_TASK_RETURN_IGNORE) {
              return TRUE;
       }

       DbusTestTaskClass * klass = DBUS_TEST_TASK_GET_CLASS(task);
       if (klass->get_passed == NULL) {
              return FALSE;
       }

       gboolean subret = klass->get_passed(task);

       if (task->priv->return_type == DBUS_TEST_TASK_RETURN_INVERT) {
              return !subret;
       }

       return subret;
}
void dbus_test_task_print ( DbusTestTask *  task,
const gchar *  message 
)

Definition at line 216 of file task.c.

{
       g_return_if_fail(DBUS_TEST_IS_TASK(task));
       g_return_if_fail(message != NULL);

       gchar * name = task->priv->name;
       if (task->priv->name_padded != NULL) {
              name = task->priv->name_padded;
       }

       g_print("%s: %s\n", name, message);

       return;
}

Here is the caller graph for this function:

void dbus_test_task_run ( DbusTestTask *  task)

Definition at line 281 of file task.c.

{
       g_return_if_fail(DBUS_TEST_IS_TASK(task));

       /* We're going to process the waiting at this level if we've been
          asked to do so */
       if (task->priv->wait_for != NULL) {
              task->priv->wait_task = g_bus_watch_name(G_BUS_TYPE_SESSION,
                                                       task->priv->wait_for,
                                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
                                                       wait_for_found,
                                                       NULL,
                                                       task,
                                                       NULL);
              g_signal_emit(G_OBJECT(task), signals[STATE_CHANGED], 0, DBUS_TEST_TASK_STATE_WAITING, NULL);
              return;
       }

       DbusTestTaskClass * klass = DBUS_TEST_TASK_GET_CLASS(task);
       if (klass->run != NULL) {
              klass->run(task);
       } else {
              task->priv->been_run = TRUE;
              g_signal_emit(G_OBJECT(task), signals[STATE_CHANGED], 0, DBUS_TEST_TASK_STATE_FINISHED, NULL);
       }

       return;
}

Here is the call graph for this function:

void dbus_test_task_set_name ( DbusTestTask *  task,
const gchar *  name 
)

Definition at line 143 of file task.c.

{
       g_return_if_fail(DBUS_TEST_IS_TASK(task));

       g_free(task->priv->name);
       g_free(task->priv->name_padded);

       task->priv->name = g_strdup(name);
       if (task->priv->padding_cnt != 0 && task->priv->name != NULL) {
              gchar * fillstr = g_strnfill(task->priv->padding_cnt - g_utf8_strlen(task->priv->name, -1), ' ');
              task->priv->name_padded = g_strconcat(task->priv->name, fillstr, NULL);
              g_free(fillstr);
       } else {
              task->priv->name_padded = NULL;
       }

       return;
}

Here is the caller graph for this function:

void dbus_test_task_set_name_spacing ( DbusTestTask *  task,
glong  chars 
)

Definition at line 163 of file task.c.

{
       g_return_if_fail(DBUS_TEST_IS_TASK(task));

       g_free(task->priv->name_padded);
       task->priv->padding_cnt = chars;

       g_return_if_fail(task->priv->padding_cnt >= g_utf8_strlen(task->priv->name, -1));

       if (chars != 0 && task->priv->name != NULL) {
              gchar * fillstr = g_strnfill(task->priv->padding_cnt - g_utf8_strlen(task->priv->name, -1), ' ');
              task->priv->name_padded = g_strconcat(task->priv->name, fillstr, NULL);
              g_free(fillstr);
       } else {
              task->priv->name_padded = NULL;
       }

       return;
}
void dbus_test_task_set_return ( DbusTestTask *  task,
DbusTestTaskReturn  ret 
)

Definition at line 203 of file task.c.

{
       g_return_if_fail(DBUS_TEST_IS_TASK(task));

       if (ret != task->priv->return_type && dbus_test_task_get_state(task) == DBUS_TEST_TASK_STATE_FINISHED) {
              g_warning("Changing return type after the task has finished");
       }

       task->priv->return_type = ret;
       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dbus_test_task_set_wait_for ( DbusTestTask *  task,
const gchar *  dbus_name 
)

Definition at line 184 of file task.c.

{
       g_return_if_fail(DBUS_TEST_IS_TASK(task));

       if (task->priv->wait_for != NULL) {
              g_free(task->priv->wait_for);
              task->priv->wait_for = NULL;
       }

       if (dbus_name == NULL) {
              return;
       }

       task->priv->wait_for = g_strdup(dbus_name);

       return;
}

Here is the caller graph for this function: