<commit_before>#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
#include <Elementary.h>
#include "elm_suite.h"

static const char pathfmt[] =  ELM_IMAGE_DATA_DIR"/images/icon_%02d.png";
static const char invalid[] = "thereisnosuchimage.png";
#define MAX_IMAGE_ID 23

typedef struct _Test_Data Test_Data;
struct _Test_Data
{
   int image_id;
   Eina_Bool success;
};

START_TEST (elm_atspi_role_get)
{
   Evas_Object *win, *image;
   Elm_Atspi_Role role;

   elm_init(1, NULL);
   win = elm_win_add(NULL, "image", ELM_WIN_BASIC);

   image = elm_image_add(win);
   role = elm_interface_atspi_accessible_role_get(image);

   ck_assert(role == ELM_ATSPI_ROLE_IMAGE);

   elm_shutdown();
}
END_TEST

static Eina_Bool
_async_error_cb(void *data, Eo *obj,
                const Eo_Event_Description *desc EINA_UNUSED,
                void *event_info EINA_UNUSED)
{
   Test_Data *td = data;
   char path[PATH_MAX];
   sprintf(path, pathfmt, td->image_id);
   efl_file_set(obj, path, NULL);
   return EO_CALLBACK_CONTINUE;
}

static Eina_Bool
_async_opened_cb(void *data, Eo *obj,
                 const Eo_Event_Description *desc EINA_UNUSED,
                 void *event_info EINA_UNUSED)
{
   Test_Data *td = data;
   const char *ff, *kk, *r1, *r2;
   char path[PATH_MAX];

   sprintf(path, pathfmt, td->image_id);
   efl_file_get(obj, &ff, &kk);
   r1 = strrchr(ff, '/');
   r2 = strrchr(path, '/');
   ck_assert(!strcmp(r1, r2));
   ck_assert(!kk);

   if (td->image_id < MAX_IMAGE_ID / 2)
     {
        td->image_id++;
        sprintf(path, pathfmt, td->image_id);
        efl_file_set(obj, path, NULL);
        return EO_CALLBACK_CONTINUE;
     }
   else if (td->image_id < MAX_IMAGE_ID)
     {
        // mini stress-test
        for (; td->image_id < MAX_IMAGE_ID;)
          {
             sprintf(path, pathfmt, ++td->image_id);
             efl_file_set(obj, path, NULL);
          }
        return EO_CALLBACK_CONTINUE;
     }

   td->success = 1;
   ecore_main_loop_quit();

   return EO_CALLBACK_CONTINUE;
}

static Eina_Bool
_timeout_cb(void *data)
{
   Test_Data *td = data;
<commit_msg>Image test: Migrate to the new event cb signature.<commit_after>#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
#include <Elementary.h>
#include "elm_suite.h"

static const char pathfmt[] =  ELM_IMAGE_DATA_DIR"/images/icon_%02d.png";
static const char invalid[] = "thereisnosuchimage.png";
#define MAX_IMAGE_ID 23

typedef struct _Test_Data Test_Data;
struct _Test_Data
{
   int image_id;
   Eina_Bool success;
};

START_TEST (elm_atspi_role_get)
{
   Evas_Object *win, *image;
   Elm_Atspi_Role role;

   elm_init(1, NULL);
   win = elm_win_add(NULL, "image", ELM_WIN_BASIC);

   image = elm_image_add(win);
   role = elm_interface_atspi_accessible_role_get(image);

   ck_assert(role == ELM_ATSPI_ROLE_IMAGE);

   elm_shutdown();
}
END_TEST

static Eina_Bool
_async_error_cb(void *data, const Eo_Event *event)
{
   Test_Data *td = data;
   char path[PATH_MAX];
   sprintf(path, pathfmt, td->image_id);
   efl_file_set(event->obj, path, NULL);
   return EO_CALLBACK_CONTINUE;
}

static Eina_Bool
_async_opened_cb(void *data, const Eo_Event *event)
{
   Test_Data *td = data;
   const char *ff, *kk, *r1, *r2;
   char path[PATH_MAX];

   sprintf(path, pathfmt, td->image_id);
   efl_file_get(event->obj, &ff, &kk);
   r1 = strrchr(ff, '/');
   r2 = strrchr(path, '/');
   ck_assert(!strcmp(r1, r2));
   ck_assert(!kk);

   if (td->image_id < MAX_IMAGE_ID / 2)
     {
        td->image_id++;
        sprintf(path, pathfmt, td->image_id);
        efl_file_set(event->obj, path, NULL);
        return EO_CALLBACK_CONTINUE;
     }
   else if (td->image_id < MAX_IMAGE_ID)
     {
        // mini stress-test
        for (; td->image_id < MAX_IMAGE_ID;)
          {
             sprintf(path, pathfmt, ++td->image_id);
             efl_file_set(event->obj, path, NULL);
          }
        return EO_CALLBACK_CONTINUE;
     }

   td->success = 1;
   ecore_main_loop_quit();

   return EO_CALLBACK_CONTINUE;
}

static Eina_Bool
_timeout_cb(void *data)
{
   Test_Data *td = data;

{'fraction_non_alphanumeric': 0.11972334843787265, 'fraction_numerical': 0.006200810875268304, 'mean_word_length': 3.36875, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7190779', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1626, 'n_words': 316}