Back to index

unity  6.0.0
Classes | Defines | Typedefs | Functions
TestPanelService.cpp File Reference
#include "config.h"
#include "panel-service.h"
#include <libindicator/indicator-object.h>

Go to the source code of this file.

Classes

struct  _TestObject
struct  _TestObjectClass

Defines

#define TEST_TYPE_OBJECT   (test_object_get_type ())
#define TEST_OBJECT(obj)
#define TEST_OBJECT_CLASS(klass)
#define TEST_IS_OBJECT(obj)
#define TEST_IS_OBJECT_CLASS(klass)
#define TEST_OBJECT_GET_CLASS(obj)
#define _DOMAIN   "/Unit/PanelService"

Typedefs

typedef struct _TestObject
typedef struct _TestObjectClass

Functions

GType test_object_get_type (void) G_GNUC_CONST
IndicatorObject * test_object_new ()
IndicatorObjectEntry * test_object_add_entry (TestObject *self, const gchar *label, const gchar *icon_name)
 G_DEFINE_TYPE (TestObject, test_object, INDICATOR_OBJECT_TYPE)
void test_object_dispose (GObject *object)
GList * test_object_get_entries (IndicatorObject *io)
guint test_object_get_location (IndicatorObject *io, IndicatorObjectEntry *entry)
void test_object_entry_activate (IndicatorObject *io, IndicatorObjectEntry *entry, guint timestamp)
void test_object_class_init (TestObjectClass *klass)
void test_object_init (TestObject *self)
void test_object_show_entry (TestObject *self, IndicatorObjectEntry *entry, guint timestamp)
guint get_n_indicators_in_result (GVariant *result)
guint get_n_entries_in_result (GVariant *result)
static void TestAllocation (void)
static void TestIndicatorLoading (void)
static void TestEmptyIndicatorObject (void)
static void TestEntryAddition (void)
static void TestEntryActivateRequest (void)
void TestPanelServiceCreateSuite ()
static void OnEntryActivateRequest (IndicatorObject *object, const gchar *entry_id, const gchar *entry_id_should_be)

Class Documentation

struct _TestObject

Definition at line 49 of file TestPanelService.cpp.

Class Members
GList * entries
IndicatorObject parent
struct _TestObjectClass

Definition at line 56 of file TestPanelService.cpp.

Class Members
IndicatorObjectClass parent_class

Define Documentation

#define _DOMAIN   "/Unit/PanelService"
#define TEST_IS_OBJECT (   obj)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
  TEST_TYPE_OBJECT))

Definition at line 37 of file TestPanelService.cpp.

#define TEST_IS_OBJECT_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_TYPE ((klass),\
  TEST_TYPE_OBJECT))

Definition at line 40 of file TestPanelService.cpp.

#define TEST_OBJECT (   obj)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((obj),\
  TEST_TYPE_OBJECT, TestObject))

Definition at line 31 of file TestPanelService.cpp.

#define TEST_OBJECT_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_CAST ((klass),\
  TEST_TYPE_OBJECT, TestObjectClass))

Definition at line 34 of file TestPanelService.cpp.

#define TEST_OBJECT_GET_CLASS (   obj)
Value:
(G_TYPE_INSTANCE_GET_CLASS ((obj),\
  TEST_TYPE_OBJECT, TestObjectClass))

Definition at line 43 of file TestPanelService.cpp.

Definition at line 29 of file TestPanelService.cpp.


Typedef Documentation

typedef struct _TestObject

Definition at line 46 of file TestPanelService.cpp.

typedef struct _TestObjectClass

Definition at line 47 of file TestPanelService.cpp.


Function Documentation

G_DEFINE_TYPE ( TestObject  ,
test_object  ,
INDICATOR_OBJECT_TYPE   
)
guint get_n_entries_in_result ( GVariant *  result)

Definition at line 215 of file TestPanelService.cpp.

{
  guint  ret = 0;
  GVariantIter* iter;
  gchar*        indicator_id;
  gchar*        entry_id;
  gchar*        entry_name_hint;
  gchar*        label;
  gboolean      label_sensitive;
  gboolean      label_visible;
  guint32       image_type;
  gchar*        image_data;
  gboolean      image_sensitive;
  gboolean      image_visible;
  gboolean      priority;

  g_variant_get(result, "(a(ssssbbusbbi))", &iter);
  while (g_variant_iter_loop(iter, "(ssssbbusbbi)",
                             &indicator_id,
                             &entry_id,
                             &entry_name_hint,
                             &label,
                             &label_sensitive,
                             &label_visible,
                             &image_type,
                             &image_data,
                             &image_sensitive,
                             &image_visible,
                             &priority))
  {
    if (g_strcmp0(entry_id, "") != 0)
      ret++;
  }

  return ret;
}

Here is the caller graph for this function:

guint get_n_indicators_in_result ( GVariant *  result)

Definition at line 173 of file TestPanelService.cpp.

{
  guint  ret = 0;
  gchar* current_object_id = NULL;
  GVariantIter* iter;
  gchar*        indicator_id;
  gchar*        entry_id;
  gchar*        entry_name_hint;
  gchar*        label;
  gboolean      label_sensitive;
  gboolean      label_visible;
  guint32       image_type;
  gchar*        image_data;
  gboolean      image_sensitive;
  gboolean      image_visible;

  g_variant_get(result, "(a(ssssbbusbbi))", &iter);
  while (g_variant_iter_loop(iter, "(ssssbbusbbi)",
                             &indicator_id,
                             &entry_id,
                             &entry_name_hint,
                             &label,
                             &label_sensitive,
                             &label_visible,
                             &image_type,
                             &image_data,
                             &image_sensitive,
                             &image_visible))
  {
    if (g_strcmp0(current_object_id, indicator_id) != 0)
    {
      ret++;
      g_free(current_object_id);
      current_object_id = g_strdup(indicator_id);
    }
  }
  g_free(current_object_id);

  return ret;
}

Here is the caller graph for this function:

static void OnEntryActivateRequest ( IndicatorObject *  object,
const gchar *  entry_id,
const gchar *  entry_id_should_be 
) [static]

Definition at line 372 of file TestPanelService.cpp.

{
  g_assert_cmpstr(entry_id, == , entry_id_should_be);
}

Here is the caller graph for this function:

IndicatorObjectEntry * test_object_add_entry ( TestObject *  self,
const gchar *  label,
const gchar *  icon_name 
)

Definition at line 140 of file TestPanelService.cpp.

{
  IndicatorObjectEntry* entry;
  g_return_val_if_fail(TEST_IS_OBJECT(self), NULL);

  entry = g_slice_new0(IndicatorObjectEntry);
  entry->label = (GtkLabel*)gtk_label_new(label);
  entry->image = icon_name ? (GtkImage*)gtk_image_new_from_icon_name(icon_name,
                                                                     GTK_ICON_SIZE_MENU) : NULL;
  entry->menu = NULL;

  self->entries = g_list_append(self->entries, entry);

  g_signal_emit(self, INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, entry, TRUE);

  return entry;
}

Here is the caller graph for this function:

void test_object_class_init ( TestObjectClass *  klass)

Definition at line 115 of file TestPanelService.cpp.

{
  GObjectClass*         obj_class = G_OBJECT_CLASS(klass);
  IndicatorObjectClass* ind_class = INDICATOR_OBJECT_CLASS(klass);

  obj_class->dispose = test_object_dispose;

  ind_class->get_entries    = test_object_get_entries;
  ind_class->get_location   = test_object_get_location;
  ind_class->entry_activate = test_object_entry_activate;
}

Here is the call graph for this function:

void test_object_dispose ( GObject *  object)

Definition at line 74 of file TestPanelService.cpp.

{
  TestObject* self = TEST_OBJECT(object);

  GList* e;
  for (e = self->entries; e; e = e->next)
  {
    g_slice_free(IndicatorObjectEntry, e->data);
  }
  g_list_free(self->entries);
  self->entries = NULL;

  G_OBJECT_CLASS(test_object_parent_class)->dispose(object);
}

Here is the caller graph for this function:

void test_object_entry_activate ( IndicatorObject *  io,
IndicatorObjectEntry *  entry,
guint  timestamp 
)

Definition at line 107 of file TestPanelService.cpp.

{

}

Here is the caller graph for this function:

GList* test_object_get_entries ( IndicatorObject *  io)

Definition at line 90 of file TestPanelService.cpp.

{
  g_return_val_if_fail(TEST_IS_OBJECT(io), NULL);

  return g_list_copy(TEST_OBJECT(io)->entries);
}

Here is the caller graph for this function:

guint test_object_get_location ( IndicatorObject *  io,
IndicatorObjectEntry *  entry 
)

Definition at line 98 of file TestPanelService.cpp.

{
  g_return_val_if_fail(TEST_IS_OBJECT(io), 0);

  return g_list_index(TEST_OBJECT(io)->entries, entry);
}

Here is the caller graph for this function:

GType test_object_get_type ( void  )
void test_object_init ( TestObject *  self)

Definition at line 128 of file TestPanelService.cpp.

{

}
IndicatorObject * test_object_new ( )

Definition at line 134 of file TestPanelService.cpp.

{
  return (IndicatorObject*)g_object_new(TEST_TYPE_OBJECT, NULL);
}

Here is the caller graph for this function:

void test_object_show_entry ( TestObject *  self,
IndicatorObjectEntry *  entry,
guint  timestamp 
)

Definition at line 161 of file TestPanelService.cpp.

{
  g_signal_emit(self, INDICATOR_OBJECT_SIGNAL_MENU_SHOW_ID, 0, entry, timestamp);
}

Here is the caller graph for this function:

static void TestAllocation ( void  ) [static]

Definition at line 275 of file TestPanelService.cpp.

{
  PanelService* service;

  service = panel_service_get_default();
  g_assert(PANEL_IS_SERVICE(service));

  g_object_unref(service);
  g_assert(PANEL_IS_SERVICE(service) == FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestEmptyIndicatorObject ( void  ) [static]

Definition at line 308 of file TestPanelService.cpp.

{
  PanelService*    service;
  IndicatorObject* object;
  GList*           objects = NULL;
  GVariant*        result;

  object = test_object_new();
  g_assert(INDICATOR_IS_OBJECT(object));
  objects = g_list_append(objects, object);

  service = panel_service_get_default_with_indicators(objects);
  g_assert(PANEL_IS_SERVICE(service));

  g_assert_cmpint(panel_service_get_n_indicators(service), == , 1);

  result = panel_service_sync(service);
  g_assert(result != NULL);

  g_assert_cmpint(get_n_indicators_in_result(result), == , 1);

  g_variant_unref(result);
  g_list_free(objects);
  g_object_unref(object);
  g_object_unref(service);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestEntryActivateRequest ( void  ) [static]

Definition at line 380 of file TestPanelService.cpp.

{
  PanelService* service;
  TestObject*   object;
  GList*        objects = NULL;
  IndicatorObjectEntry* entry;
  gchar*        id;

  object = (TestObject*)test_object_new();
  entry = test_object_add_entry(object, "Hello", "gtk-apply");
  id = g_strdup_printf("%p", entry);
  g_assert(INDICATOR_IS_OBJECT(object));
  objects = g_list_append(objects, object);

  service = panel_service_get_default_with_indicators(objects);
  g_assert(PANEL_IS_SERVICE(service));

  g_signal_connect(service, "entry-activate-request",
                   G_CALLBACK(OnEntryActivateRequest),
                   id);

  test_object_show_entry(object, entry, 1234);

  g_free(id);
  g_list_free(objects);
  g_object_unref(object);
  g_object_unref(service);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestEntryAddition ( void  ) [static]

Definition at line 336 of file TestPanelService.cpp.

{
  PanelService* service;
  TestObject*   object;
  GList*        objects = NULL;
  GVariant*     result;
  int           i;

  object = (TestObject*)test_object_new();
  test_object_add_entry(object, "Hello", "gtk-apply");
  g_assert(INDICATOR_IS_OBJECT(object));
  objects = g_list_append(objects, object);

  service = panel_service_get_default_with_indicators(objects);
  g_assert(PANEL_IS_SERVICE(service));

  result = panel_service_sync(service);
  g_assert(result != NULL);
  g_assert_cmpint(get_n_entries_in_result(result), == , 1);

  for (i = 2; i < 10; i++)
  {
    g_variant_unref(result);

    test_object_add_entry(object, "Bye", "gtk-forward");
    result = panel_service_sync(service);
    g_assert_cmpint(get_n_entries_in_result(result), == , i);
  }

  g_variant_unref(result);
  g_list_free(objects);
  g_object_unref(object);
  g_object_unref(service);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestIndicatorLoading ( void  ) [static]

Definition at line 287 of file TestPanelService.cpp.

{
  PanelService*    service;
  IndicatorObject* object;
  GList*           objects = NULL;

  object = test_object_new();
  g_assert(INDICATOR_IS_OBJECT(object));
  objects = g_list_append(objects, object);

  service = panel_service_get_default_with_indicators(objects);
  g_assert(PANEL_IS_SERVICE(service));

  g_assert_cmpint(panel_service_get_n_indicators(service), == , 1);

  g_list_free(objects);
  g_object_unref(object);
  g_object_unref(service);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 263 of file TestPanelService.cpp.

{
#define _DOMAIN "/Unit/PanelService"

  g_test_add_func(_DOMAIN"/Allocation", TestAllocation);
  g_test_add_func(_DOMAIN"/IndicatorLoading", TestIndicatorLoading);
  g_test_add_func(_DOMAIN"/EmptyIndicatorObject", TestEmptyIndicatorObject);
  g_test_add_func(_DOMAIN"/EntryAddition", TestEntryAddition);
  g_test_add_func(_DOMAIN"/EntryActivateRequest", TestEntryActivateRequest);
}

Here is the call graph for this function:

Here is the caller graph for this function: