Back to index

unity  6.0.0
Functions
unitya11ytests.cpp File Reference
#include "unitya11ytests.h"
#include <glib.h>
#include "unitya11y.h"
#include "unity-util-accessible.h"
#include "nux-view-accessible.h"
#include "nux-base-window-accessible.h"
#include "nux-layout-accessible.h"
#include <Nux/Button.h>
#include "Launcher.h"
#include "LauncherIcon.h"
#include "SimpleLauncherIcon.h"
#include "PanelView.h"
#include "DashView.h"
#include "unity-launcher-accessible.h"
#include "unity-launcher-icon-accessible.h"
#include "unity-panel-view-accessible.h"

Go to the source code of this file.

Functions

static gboolean a11y_unit_test_destroy_management (void)
static gboolean a11y_unit_test_hash_table_destroy_management (void)
 This unit test checks if the hash table destroy management is working:
static gboolean a11y_unit_test_launcher_connection (void)
 This unit test checks if the launcher connection process works.
static gboolean a11y_unit_test_children_addition (void)
 This unit test checks if the launcher connection process works.
void unity_run_a11y_unit_tests (void)

Function Documentation

static gboolean a11y_unit_test_children_addition ( void  ) [static]

This unit test checks if the launcher connection process works.

Definition at line 251 of file unitya11ytests.cpp.

{
  nux::View* view[3];
  AtkObject* view_accessible[3];
  nux::Layout* layout[2];
  AtkObject* layout_accessible[2];
  gint i = 0;

  /* Test setting a layout on a view  */
  view[0] = new nux::Button("Test");
  view[0]->SinkReference();
  view_accessible[0] = unity_a11y_get_accessible(view[0]);

  for (i = 0; i < 2; i++)
  {
    layout[i] = new nux::Layout();
    layout[i]->SinkReference();
    layout_accessible[i] = unity_a11y_get_accessible(layout[i]);
  }

  view[0]->SetLayout(layout[0]);
  view[0]->SetLayout(layout[0]);

  view[0]->UnReference();
  g_object_unref(view_accessible[0]);

  for (i = 0; i < 2; i++)
  {
    layout[i]->UnReference();
    g_object_unref(layout_accessible[i]);
  }

  /* Test adding a view on a layout */
  layout[0] = new nux::Layout();
  layout[0]->SinkReference();
  layout_accessible[0] = unity_a11y_get_accessible(layout[0]);

  for (i = 0; i < 3; i ++)
  {
    view[i] = new nux::Button("Test");
    view[i]->SinkReference();
    view_accessible[i] = unity_a11y_get_accessible(view[i]);

    layout[0]->AddView(view[i]);
  }

  /* when this is removed it should be notified the removal with index 1*/
  layout[0]->RemoveChildObject(view[1]);
  layout[0]->UnReference();
  for (i = 0; i < 3; i++)
  {
    view[i]->UnReference();
    g_object_unref(view_accessible [i]);
  }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean a11y_unit_test_destroy_management ( void  ) [static]

Definition at line 55 of file unitya11ytests.cpp.

{
  unity::QuicklistView* quicklist = NULL;
  AtkObject* accessible = NULL;
  nux::Object* base_object = NULL;
  AtkStateSet* state_set = NULL;

  quicklist = new unity::QuicklistView();
  quicklist->SinkReference();
  accessible = unity_a11y_get_accessible(quicklist);

  base_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
  if (base_object != quicklist)
  {
    g_debug("[a11y] destroy management unit test: base object"
            " different to the original one");
    return FALSE;
  }

  if (quicklist->UnReference() == false)
  {
    g_debug("[a11y] destroy management unit test: base object not destroyed");
    return FALSE;
  }

  base_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
  if (base_object != NULL)
  {
    g_debug("[a11y] destroy management unit test: base object"
            " not NULL after base object destruction");
    return FALSE;
  }

  state_set = atk_object_ref_state_set(accessible);
  if (!atk_state_set_contains_state(state_set, ATK_STATE_DEFUNCT))
  {
    g_debug("[a11y] destroy management unit test: accessible object"
            " doesn't include DEFUNCT state");
    return FALSE;
  }

  g_object_unref(state_set);
  g_object_unref(accessible);

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean a11y_unit_test_hash_table_destroy_management ( void  ) [static]

This unit test checks if the hash table destroy management is working:

  • If the hash table removes properly the accessible object once it is destroyed.

Definition at line 109 of file unitya11ytests.cpp.

{
  unity::QuicklistView* quicklist = NULL;
  nux::Layout* layout = NULL;
  AtkObject* accessible = NULL;
  guint prev_hash_size = 0;
  guint hash_size = 0;

  /* test the hash table management with the accessible destroy */

  prev_hash_size = g_hash_table_size(_unity_a11y_get_accessible_table());

  layout = new nux::Layout();
  layout->SinkReference();
  accessible = unity_a11y_get_accessible(layout);

  if (accessible == NULL)
  {
    g_debug("[a11y] hash table destroy management unit test: error creating"
            " the accessible object (accessible == NULL)");
    return FALSE;
  }

  hash_size = g_hash_table_size(_unity_a11y_get_accessible_table());

  if ((hash_size - prev_hash_size) != 1)
  {
    g_debug("[a11y] hash table destroy management unit test: accessible object"
            " not added to the hash table after his creation");
    return FALSE;
  }

  prev_hash_size = g_hash_table_size(_unity_a11y_get_accessible_table());

  g_object_unref(accessible);

  hash_size = g_hash_table_size(_unity_a11y_get_accessible_table());

  if ((prev_hash_size - hash_size) != 1)
  {
    g_debug("[a11y] hash table destroy management unit test: accessible object"
            " not removed from the hash table after his destruction");
    return FALSE;
  }

  layout->UnReference();

  /* Test the hash table management after the object destroy */

  prev_hash_size = g_hash_table_size(_unity_a11y_get_accessible_table());

  quicklist = new unity::QuicklistView();
  quicklist->SinkReference();
  accessible = unity_a11y_get_accessible(quicklist);

  if (accessible == NULL)
  {
    g_debug("[a11y] hash table destroy management unit test: error creating"
            " the accessible object (accessible == NULL)");
    return FALSE;
  }

  hash_size = g_hash_table_size(_unity_a11y_get_accessible_table());

  if ((hash_size - prev_hash_size) != 1)
  {
    g_debug("[a11y] hash table destroy management unit test: accessible object"
            " not added to the hash table after his creation");
    return FALSE;
  }

  prev_hash_size = g_hash_table_size(_unity_a11y_get_accessible_table());

  if (quicklist->UnReference() == false)
  {
    g_debug("[a11y] hash table destroy management unit test: base object not destroyed");
    return FALSE;
  }

  hash_size = g_hash_table_size(_unity_a11y_get_accessible_table());

  if ((prev_hash_size - hash_size) != 1)
  {
    g_debug("[a11y] hash table destroy management unit test: accessible object"
            " not removed from the hash table after base object destruction");
    return FALSE;
  }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean a11y_unit_test_launcher_connection ( void  ) [static]

This unit test checks if the launcher connection process works.

Definition at line 204 of file unitya11ytests.cpp.

{
  Launcher* launcher = NULL;
  nux::BaseWindow* window = NULL;
  AtkObject* launcher_accessible = NULL;
  LauncherIcon* launcher_icon = NULL;
  AtkObject* launcher_icon_accessible = NULL;

  window = new nux::BaseWindow(TEXT(""));
  launcher = new Launcher(window, NULL);
  launcher->SinkReference();
  launcher_accessible = unity_a11y_get_accessible(launcher);

  if (!UNITY_IS_LAUNCHER_ACCESSIBLE(launcher_accessible))
  {
    g_debug("[a11y] wrong launcher accessible type");
    return FALSE;
  }
  else
  {
    g_debug("[a11y] Launcher accessible created correctly");
  }

  launcher_icon = new SimpleLauncherIcon();
  launcher_icon->SinkReference();
  launcher_icon_accessible = unity_a11y_get_accessible(launcher_icon);

  if (!UNITY_IS_LAUNCHER_ICON_ACCESSIBLE(launcher_icon_accessible))
  {
    g_debug("[a11y] wrong launcher icon accessible type");
    return FALSE;
  }
  else
  {
    g_debug("[a11y] LauncherIcon accessible created correctly");
  }

  launcher->UnReference();
  launcher_icon->UnReference();

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity_run_a11y_unit_tests ( void  )

Definition at line 312 of file unitya11ytests.cpp.

{
  if (a11y_unit_test_destroy_management())
    g_debug("[a11y] destroy management unit test: SUCCESS");
  else
    g_debug("[a11y] destroy management unit test: FAIL");

  if (a11y_unit_test_hash_table_destroy_management())
    g_debug("[a11y] hash table destroy management unit test: SUCCESS");
  else
    g_debug("[a11y] hash table destroy management unit test: FAIL");

  if (a11y_unit_test_launcher_connection())
    g_debug("[a11y] launcher connection: SUCCESS");
  else
    g_debug("[a11y] launcher connection: FAIL");

  if (a11y_unit_test_children_addition())
    g_debug("[a11y] children addition: SUCCESS");
  else
    g_debug("[a11y] children addition: FAIL");
}

Here is the call graph for this function: