Add a check for lack of memory
[platform/core/uifw/at-spi2-atk.git] / test / screen-review-test.c
index 2d63aa2..1b5fa2e 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <stdlib.h>
 #include "../cspi/spi-private.h"
 
@@ -90,7 +90,6 @@
 
 static void report_screen_review_line  (const AccessibleEvent *event, void *user_data);
 
-static gint n_elements_traversed = 0;
 static AccessibleEventListener *mouseclick_listener;
 
 typedef struct _BoundaryRect {
@@ -123,16 +122,6 @@ static gboolean isJava = FALSE;
 int
 main (int argc, char **argv)
 {
-  int i, j;
-  int n_desktops;
-  int n_apps;
-  char *s;
-  GTimer *timer;
-  gdouble elapsed_time;
-  Accessible *desktop;
-  Accessible *application;
-  const char *modules;
-
   SPI_init ();
 
   mouseclick_listener = SPI_createAccessibleEventListener (
@@ -161,13 +150,11 @@ main (int argc, char **argv)
 static inline gboolean
 chunk_bounds_within (TextChunk *chunk, TextChunk *test_chunk)
 {
-       int x1, x2, tx1, tx2;
+       int x1, tx1;
        gboolean gtx1, ltx2;
 
        x1 = chunk->clip_bounds.x;
-       x2 = x1 + chunk->clip_bounds.width;
        tx1 = test_chunk->clip_bounds.x;
-       tx2 = tx1 + test_chunk->clip_bounds.width;
        gtx1 = (chunk->clip_bounds.x >= test_chunk->clip_bounds.x);
        ltx2 = (chunk->clip_bounds.x + chunk->clip_bounds.width
                <= test_chunk->clip_bounds.x + test_chunk->clip_bounds.width);
@@ -314,7 +301,7 @@ text_chunk_split_insert (GList *chunk_list, GList *iter, TextChunk *chunk)
 static void
 print_chunk_debug (TextChunk *chunk, char *opname, GList *prev, GList *next)
 {
-       fprintf (stderr, "%sing chunk %s between %s and %s; %d-%d\n",
+       fprintf (stderr, "%sing chunk %s between %s and %s; %ld-%ld\n",
                 opname,
                 chunk->string,
                 (prev ? ((TextChunk *) prev->data)->string : "<null>"),
@@ -331,10 +318,10 @@ text_chunk_list_head_clip (GList *text_chunk_list,
 {
        GList *target, *iter = next, *prev;
        prev = iter->prev;
-//     if (chunk->string && strlen (chunk->string)) { 
+/*     if (chunk->string && strlen (chunk->string)) { */
                text_chunk_list =
                        g_list_insert_before (text_chunk_list, next, chunk);
-//     }
+/*     }*/
        while (iter && CHUNK_BOUNDS_SPANS_END (chunk, (TextChunk *)iter->data)) {
 #ifdef CLIP_DEBUG                      
                        fprintf (stderr, "deleting %s\n",
@@ -461,7 +448,6 @@ review_buffer_get_text_chunk (ScreenReviewBuffer *reviewBuffer,
        AccessibleText *text = NULL;
        AccessibleRole role;
        TextChunk *text_chunk;
-       BoundaryRect start_char_bounds, end_char_bounds;
        char *s = NULL;
        int offset;
        long start, end;
@@ -587,13 +573,14 @@ review_buffer_get_text_chunk (ScreenReviewBuffer *reviewBuffer,
        return text_chunk;
 }
 
+#ifdef CHUNK_LIST_DEBUG
 static void
 debug_chunk_list (GList *iter)
 {
        TextChunk *chunk;
        while (iter) {
                chunk = (TextChunk *)iter->data;
-               fprintf (stderr, "Chunk %s, clip %d-%d, text %d-%d\n",
+               fprintf (stderr, "Chunk %s, clip %ld-%ld, text %ld-%ld\n",
                         chunk->string,
                         chunk->clip_bounds.x,
                         chunk->clip_bounds.x + chunk->clip_bounds.width,
@@ -602,6 +589,7 @@ debug_chunk_list (GList *iter)
                iter = iter->next;
        }
 }
+#endif
 
 static void
 clip_into_buffers (Accessible *accessible,  BoundaryRect* parentClipBounds[],
@@ -747,7 +735,7 @@ string_guess_clip (TextChunk *chunk)
                        start_offset = len * (chunk->text_bounds.x - b.x) / b.width;
                        end_offset = len * (chunk->text_bounds.x +
                                            chunk->text_bounds.width - b.x) / b.width;
-                       fprintf (stderr, "String len %d, clipped to %d-%d\n",
+                       fprintf (stderr, "String len %ld, clipped to %ld-%ld\n",
                                 len, start_offset, end_offset);
                        len = end_offset - start_offset;
                        sp = g_utf8_offset_to_pointer (chunk->string, start_offset);
@@ -765,7 +753,6 @@ static char*
 text_chunk_get_clipped_string (TextChunk *chunk)
 {
        char *s, *string = "";
-       int i;
        long start = chunk->start_offset, end = chunk->end_offset;
        long word_start, word_end, range_end;
        BoundaryRect start_bounds, end_bounds;
@@ -895,7 +882,6 @@ text_chunk_list_to_string (GList *iter)
        char *s = "";
        char *string;
        TextChunk *chunk = NULL;
-       int offset = 0;
        while (iter) {
                chunk = (TextChunk *)iter->data;
                if (chunk) {
@@ -985,14 +971,14 @@ static char *
 get_screen_review_line_at (int x, int y)
 {
   char *string;
-  Accessible *desktop, *app, *toplevel, *child;
+  Accessible *desktop, *app, *toplevel;
   AccessibleComponent *component;
   AccessibleStateSet *states;
   GList *toplevels = NULL, *actives = NULL, *iter;
   ScreenReviewBuffer* reviewBuffers[SPI_LAYER_LAST_DEFINED];
   BoundaryRect* clip_bounds[SPI_LAYER_LAST_DEFINED];
   BoundaryRect toplevel_bounds;
-  int n_apps, n_toplevels, n_children, app_n, toplevel_n, child_n;
+  int n_apps, n_toplevels, app_n, toplevel_n;
   GTimer *timer = g_timer_new ();
   int i;
 
@@ -1047,8 +1033,8 @@ get_screen_review_line_at (int x, int y)
          if (Accessible_isComponent (toplevel)) {
              /* make sure toplevel is visible and not iconified or shaded */
              states = Accessible_getStateSet (toplevel);
-             if (AccessibleStateSet_contains (states, SPI_STATE_VISIBLE)
-                 && !AccessibleStateSet_contains (states, SPI_STATE_ICONIFIED)
+             if ((AccessibleStateSet_contains (states, SPI_STATE_VISIBLE)
+                 && (!AccessibleStateSet_contains (states, SPI_STATE_ICONIFIED)))
                  || isJava) { /* isJava hack! */
                      component = Accessible_getComponent (toplevel);
                      AccessibleComponent_getExtents (component,
@@ -1128,7 +1114,7 @@ report_screen_review_line (const AccessibleEvent *event, void *user_data)
 }
 
 void
-test_exit ()
+test_exit (void)
 {
   SPI_deregisterGlobalEventListenerAll (mouseclick_listener);
   AccessibleEventListener_unref (mouseclick_listener);