]> Pileus Git - ~andy/gtk/blob - gtk/a11y/tests/testtextlib.c
gail: No need to include modules/other in CFLAGS anymore
[~andy/gtk] / gtk / a11y / tests / testtextlib.c
1 #include <string.h>
2 #include <stdio.h>
3 #include "testtextlib.h"
4
5 static AtkAttributeSet *attrib = NULL;
6 static char result_string[2][6] = {"FALSE", "TRUE"};
7
8 /**
9  * setup_gui:
10  * @obj: An @AtkObject
11  * @test: The callback to be run when the "Run Tests" button
12  *   in the GUI is clicked.
13  *
14  * Sets up the GUI windows.
15  *
16  * Returns: the window number, or -1 if failure.
17  **/
18 gint setup_gui(AtkObject *obj, TLruntest test)
19 {
20   gchar *paramnames[MAX_PARAMS];
21   gchar *defaults[MAX_PARAMS];
22   static OutputWindow *tow = NULL;
23   gint  window;
24   
25   if (tow)
26     window = create_windows(obj, test, &tow);
27   else
28     window = create_windows(obj, test, &tow);
29
30   if (window == -1)
31     return -1;
32
33   /* Get Text [at|after|before] Offset Tests */
34   paramnames[0] = "offset";
35   defaults[0] = "1"; 
36   add_test(window, "atk_text_get_text_after_offset", 1,  paramnames, defaults);
37   add_test(window, "atk_text_get_text_before_offset", 1, paramnames, defaults);
38   add_test(window, "atk_text_get_text_at_offset",1 , paramnames, defaults);
39   
40   /* Get Character Count Test */
41   add_test(window, "atk_text_get_character_count", 0, NULL, NULL); 
42
43   /* Get Character At Offset Test */
44   paramnames[0] = "offset";
45   defaults[0] = "1";
46   add_test(window, "atk_text_get_character_at_offset", 1, paramnames, defaults);
47    
48   /* Get Text Test */
49   paramnames[0] = "position 1";
50   paramnames[1] = "position 2";
51   defaults[0] = "0";
52   defaults[1] = "5";
53   add_test(window, "atk_text_get_text", 2, paramnames, defaults); 
54
55   /* Caret Tests */
56   add_test(window, "atk_text_get_caret_offset", 0, NULL, NULL); 
57
58   paramnames[0] = "offset";
59   defaults[0] = "1";
60   add_test(window, "atk_text_set_caret_offset", 1, paramnames, defaults);
61
62   /* Selection Tests */
63   add_test(window, "atk_text_get_n_selections", 0, NULL, NULL);
64     
65   paramnames[0] = "selection no";
66   defaults[0] = "0";
67   add_test(window, "atk_text_get_selection", 1, paramnames, defaults);  
68
69   paramnames[0] = "start";
70   paramnames[1] = "end";
71   defaults[0] = "3";
72   defaults[1] = "8";
73   add_test(window, "atk_text_add_selection", 2, paramnames, defaults); 
74
75   paramnames[0] = "selection no";
76   paramnames[1] = "start";
77   paramnames[2] = "end";
78   defaults[0] = "0";
79   defaults[1] = "5";
80   defaults[2] = "7"; 
81   add_test(window, "atk_text_set_selection", 3, paramnames, defaults);
82
83   paramnames[0] = "selection no";
84   defaults[0] = "0";
85   add_test(window, "atk_text_remove_selection", 1, paramnames, defaults);
86
87   paramnames[0] = "offset";
88   defaults[0] = "36";
89   add_test(window, "atk_text_get_run_attributes", 1, paramnames, defaults);
90
91   add_test(window, "atk_text_get_default_attributes", 0, paramnames, defaults);
92
93   paramnames[0] = "offset";
94   paramnames[1] = "coord mode";
95   defaults[0] = "0";
96   defaults[1] = "ATK_XY_SCREEN";
97   add_test(window, "atk_text_get_character_extents", 2, paramnames, defaults);
98
99   paramnames[0] = "x";
100   paramnames[1] = "y";
101   paramnames[2] = "coord mode";
102   defaults[0] = "106";
103   defaults[1] = "208";
104   defaults[2] = "ATK_XY_SCREEN";
105   add_test(window, "atk_text_get_offset_at_point", 3, paramnames, defaults);
106
107   /* Editable Text Tests */
108   if (ATK_IS_EDITABLE_TEXT(obj)) 
109   {
110
111     paramnames[0] = "start";
112     paramnames[1] = "end";
113     defaults[0] = "20";
114     defaults[1] = "27";
115     add_test(window, "atk_editable_text_set_run_attributes", 2, paramnames, defaults);
116       
117     paramnames[0] = "start";
118     paramnames[1] = "end";
119     defaults[0] = "3";
120     defaults[1] = "5";
121     add_test(window, "atk_editable_text_cut_text", 2, paramnames, defaults);
122
123     paramnames[0] = "position";
124     defaults[0] = "8";
125     add_test(window, "atk_editable_text_paste_text", 1, paramnames, defaults);
126
127     paramnames[0] = "start";
128     paramnames[1] = "end";
129     defaults[0] = "15";
130     defaults[1] = "20";
131     add_test(window, "atk_editable_text_delete_text", 2, paramnames, defaults);
132     paramnames[0] = "start";
133     paramnames[1] = "end";
134     defaults[0] = "5";
135     defaults[1] = "20";
136     add_test(window, "atk_editable_text_copy_text", 2, paramnames, defaults); 
137
138     paramnames[0] = "insert text";
139     paramnames[1] = "position";
140     defaults[0] = "this is my insert";
141     defaults[1] = "15";
142     add_test(window, "atk_editable_text_insert_text", 2, paramnames, defaults);
143   }
144   return window;
145 }
146
147 /**
148  * add_handlers:
149  * @obj: An #AtkObject
150  *
151  * Sets up text signal handlers.
152  *
153  **/
154 void add_handlers(AtkObject *obj)
155 {
156   if (!already_accessed_atk_object(obj))
157   {
158     /* Set up signal handlers */
159
160     g_print ("Adding signal handler\n");
161     g_signal_connect_closure_by_id (obj,
162                 g_signal_lookup ("text_caret_moved", G_OBJECT_TYPE (obj)),
163                 0,
164                 g_cclosure_new (G_CALLBACK (_notify_caret_handler),
165                         NULL, NULL),
166                 FALSE);
167
168     g_signal_connect_closure (obj, "text_changed::insert",
169                 g_cclosure_new (G_CALLBACK (_notify_text_insert_handler),
170                         NULL, NULL),
171                 FALSE);
172
173     g_signal_connect_closure (obj, "text_changed::delete",
174                 g_cclosure_new (G_CALLBACK (_notify_text_delete_handler),
175                         NULL, NULL),
176                 FALSE);
177   }
178 }
179
180 /**
181  * notify_text_insert_handler:
182  * @obj: A #Gobject
183  * @start_offset: Start offset of insert
184  * @end_offset: End offset of insert.
185  * 
186  * Text inserted singal handler
187  **/
188 void
189 _notify_text_insert_handler (GObject *obj, int start_offset, int end_offset)
190 {
191   g_print ("SIGNAL - Text inserted at position %d, length %d!\n",
192     start_offset, end_offset);
193 }
194
195 /**
196  * notify_text_delete_handler:
197  * @obj: A #Gobject
198  * @start_offset: Start offset of delete
199  * @end_offset: End offset of delete.
200  * 
201  * Text deleted singal handler
202  **/
203 void
204 _notify_text_delete_handler (GObject *obj, int start_offset, int end_offset)
205 {
206   g_print ("SIGNAL - Text deleted at position %d, length %d!\n",
207     start_offset, end_offset);
208 }
209
210 /**
211  * notify_caret_handler:
212  * @obj: A #Gobject
213  * @position: Caret position
214  * 
215  * Caret (cursor) moved signal handler.
216  **/
217 void
218 _notify_caret_handler (GObject *obj, int position)
219 {
220   g_print ("SIGNAL - The caret moved to position %d!\n", position);
221 }
222
223 /**
224  * runtest:
225  * @obj: An #AtkObject
226  * @win_val: The window number
227  *
228  * The callback to run when the "Run Tests" button on the
229  * Test GUI is clicked.
230  **/
231 void
232 runtest(AtkObject *obj, gint win_val)
233 {
234   gint        i, size;
235   gunichar    uni_char;
236   gchar       output[MAX_LINE_SIZE];
237   gchar       **testsOn;
238  
239   testsOn = tests_set(win_val, &size);
240
241   for(i = 0; i < size; i++)
242   {
243     gint      param_int1, param_int2, start, end, j, x, y, height, width;
244     gchar     *param_string1, *param_string2, *param_string3, *text;
245     gboolean  result;
246     gint index;
247
248     if (strcmp(testsOn[i], "atk_text_get_text_at_offset") == 0)
249     {
250       param_string1 = get_arg_of_func(win_val, "atk_text_get_text_at_offset", "offset");  
251       param_int1 = string_to_int(param_string1);
252       
253       _run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_WORD_END);
254       _run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_WORD_START);
255       _run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_LINE_END);
256       _run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_LINE_START);
257       _run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_END);
258       _run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_START);
259       _run_offset_test(obj, "at", param_int1, ATK_TEXT_BOUNDARY_CHAR);
260     }
261     
262     if (strcmp(testsOn[i], "atk_text_get_text_after_offset") == 0)
263     {
264       param_string1 = get_arg_of_func(win_val, "atk_text_get_text_after_offset", "offset");  
265       param_int1 = string_to_int(param_string1);
266
267       _run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_WORD_END);
268       _run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_WORD_START);
269       _run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_LINE_END);
270       _run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_LINE_START);
271       _run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_END);
272       _run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_START);
273       _run_offset_test(obj, "after", param_int1, ATK_TEXT_BOUNDARY_CHAR);
274     }
275
276     if (strcmp(testsOn[i], "atk_text_get_text_before_offset") == 0)
277     {
278       param_string1 = get_arg_of_func(win_val, "atk_text_get_text_before_offset", "offset");  
279       param_int1 = string_to_int(param_string1);
280       
281       _run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_WORD_END);
282       _run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_WORD_START);
283       _run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_LINE_END);
284       _run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_LINE_START);
285       _run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_END);
286       _run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_SENTENCE_START);
287       _run_offset_test(obj, "before", param_int1, ATK_TEXT_BOUNDARY_CHAR);
288     }
289     
290     if (strcmp(testsOn[i], "atk_text_get_character_count") == 0)
291     {
292       param_int1 = atk_text_get_character_count (ATK_TEXT (obj));
293       sprintf(output, "\nText character count: %d\n", param_int1);  
294       set_output_buffer(output);
295     }
296     
297     if (strcmp(testsOn[i], "atk_text_get_character_at_offset") == 0)
298     {
299       param_string1 = get_arg_of_func(win_val, "atk_text_get_character_at_offset",
300         "offset"); 
301       uni_char = atk_text_get_character_at_offset (ATK_TEXT(obj),
302         string_to_int(param_string1));
303       sprintf(output, "\nCharacter at offset %d: |%x|\n",
304         string_to_int(param_string1), uni_char);
305       set_output_buffer(output);
306     }
307  
308     if (strcmp(testsOn[i], "atk_text_get_text") == 0)
309     {
310       param_string1 =  get_arg_of_func(win_val, "atk_text_get_text", "position 1");
311       param_string2 = get_arg_of_func(win_val, "atk_text_get_text", "position 2");
312       text = atk_text_get_text (ATK_TEXT (obj), string_to_int(param_string1),
313         string_to_int(param_string2));
314       sprintf(output, "\nText %d, %d: %s\n", string_to_int(param_string1),
315         string_to_int(param_string2), text);
316       g_free (text);  
317       set_output_buffer(output);
318     }
319
320     if (strcmp(testsOn[i], "atk_text_get_caret_offset") == 0)
321     {
322       param_int1 = atk_text_get_caret_offset (ATK_TEXT (obj));
323       if (param_int1 == -1)
324         sprintf(output, "\nCaret offset: |Not Supported|\n");  
325       else
326         sprintf(output, "\nCaret offset: %d\n", param_int1);  
327       set_output_buffer(output);
328     }
329
330     if (strcmp(testsOn[i], "atk_text_set_caret_offset") == 0)
331     {
332       param_string1 = get_arg_of_func(win_val, "atk_text_set_caret_offset", "offset");
333       atk_text_set_caret_offset(ATK_TEXT(obj), string_to_int(param_string1));
334       sprintf(output, "\nPutting caret at offset: |%d|\n",
335         string_to_int(param_string1));
336       param_int1 = atk_text_get_caret_offset (ATK_TEXT (obj));
337
338       if (param_int1 == -1)
339         sprintf(output, "\nCaret offset: |Not Supported|\n");
340       else
341         sprintf(output, "\nCaret offset was set at: |%d|\n", param_int1);
342
343       set_output_buffer(output);
344     }
345     
346     if (strcmp(testsOn[i], "atk_text_get_n_selections") == 0)
347     {
348       param_int1 = atk_text_get_n_selections(ATK_TEXT(obj));
349       if (param_int1 == -1)
350       {
351         sprintf(output, "\nNo selected regions\n");
352         set_output_buffer(output);
353       }
354
355       for (j = 0; j < param_int1; j++)
356       {
357         sprintf(output, "\nNumber of selected text regions is: |%d|\n", j);  
358         set_output_buffer(output);
359
360         text = atk_text_get_selection(ATK_TEXT(obj), j, &start, &end);
361         if (text != NULL)
362         {
363           sprintf(output, "\nSelected text for region %d is: |%s|\n", j, text);
364           set_output_buffer(output);
365           sprintf(output,
366             "\nStart selection bounds: %d\tEnd selection bounds: %d\n",
367             start, end);
368         }
369         else
370         {
371           sprintf(output, "\nNo selected region %d\n", j);
372         }
373
374         set_output_buffer(output);
375       }
376     }
377
378     if (strcmp(testsOn[i], "atk_text_add_selection") == 0)
379     {
380       param_string1 = get_arg_of_func(win_val, "atk_text_add_selection", "start");
381       param_string2 = get_arg_of_func(win_val, "atk_text_add_selection", "end");
382       result = atk_text_add_selection(ATK_TEXT(obj),
383         string_to_int(param_string1), string_to_int(param_string2));   
384       sprintf(output, "\nSet selection bounds between %d, and %d: %s",
385         string_to_int(param_string1), string_to_int(param_string2),
386         result_string[result]);
387       set_output_buffer(output);
388       
389       param_int1 = atk_text_get_n_selections(ATK_TEXT(obj));
390       for (j = 0; j < param_int1; j++)
391       {
392         sprintf(output, "\nNumber of selected text region is: %d\n", j);
393         set_output_buffer(output);
394         text = atk_text_get_selection(ATK_TEXT(obj), j, &start, &end);
395
396         if (text != NULL)
397         {
398           sprintf(output, "\nSelected text for region %d is: |%s|\n", j, text);
399           set_output_buffer(output);
400           sprintf(output,
401             "\nStart selection bounds: %d\tEnd selection bounds: %d\n",
402             start, end);
403         }
404         else
405         {
406           sprintf(output, "\nNo selected region %d\n", j);
407         }
408
409         set_output_buffer(output);
410       }
411     }
412       
413     if (strcmp(testsOn[i], "atk_text_get_selection") == 0)
414     {
415       param_string1 = get_arg_of_func(win_val, "atk_text_get_selection", "selection no");
416       text = atk_text_get_selection(ATK_TEXT(obj),
417         string_to_int(param_string1), &start, &end);
418
419       if (text != NULL)
420       {
421         sprintf(output, "\nSelected text for region %d is: |%s|\n",
422           string_to_int(param_string1), text);
423         set_output_buffer(output);
424         sprintf(output,
425           "\nStart selection bounds: %d\t End selection bounds: %d\n",
426           start, end);
427       }
428       else
429       {
430         sprintf(output, "\nNo selected region %d\n", string_to_int(param_string1));
431       }
432
433       set_output_buffer(output);
434     }
435
436     if (strcmp(testsOn[i], "atk_text_set_selection") == 0)
437     {
438       param_string1 = get_arg_of_func(win_val, "atk_text_set_selection", "selection no");
439       param_string2 = get_arg_of_func(win_val, "atk_text_set_selection", "start");
440       param_string3 = get_arg_of_func(win_val, "atk_text_set_selection", "end");
441       result = atk_text_set_selection(ATK_TEXT(obj), string_to_int(param_string1),
442         string_to_int(param_string2), string_to_int(param_string3));
443       sprintf(output, "Set selection %d's bounds between %d and %d: %s\n",
444         string_to_int(param_string1), string_to_int(param_string2),
445         string_to_int(param_string3), result_string[result]);
446       set_output_buffer(output);
447       text = atk_text_get_selection(ATK_TEXT(obj), string_to_int(param_string1),
448         &start, &end);
449
450       if (text != NULL)
451       {
452         sprintf(output, "Selected text for the reset region %d is: |%s|\n",
453           string_to_int(param_string1), text);
454         set_output_buffer(output);
455         sprintf(output,
456           "\nNew start selection bounds: %d\tNew end selection bounds: %d\n",
457           start, end);
458       }
459       else
460       {
461         sprintf(output, "\nNo selected region %d\n", string_to_int(param_string1));
462       }
463
464       set_output_buffer(output);
465     }
466     
467     if (strcmp(testsOn[i], "atk_text_remove_selection") == 0)
468     {
469       param_string1 = get_arg_of_func(win_val, "atk_text_remove_selection", "selection no");
470       result = atk_text_remove_selection(ATK_TEXT(obj), string_to_int(param_string1));
471       sprintf(output, "Remove selection for region %d: %s\n",
472         string_to_int(param_string1), result_string[result]);
473       set_output_buffer(output);
474       text = atk_text_get_selection(ATK_TEXT(obj),
475         string_to_int(param_string1), &start, &end);
476
477       if (text != NULL)
478         sprintf(output, "\nRemoved regions text should be empty instead of: %s", text);
479       else
480         sprintf(output, "\nRemoved regions text should be empty, this is: ||");
481
482       set_output_buffer(output);
483     }
484
485     if (strcmp(testsOn[i], "atk_text_get_run_attributes") == 0)
486     {
487       gint test_int;
488       param_string1 = get_arg_of_func(win_val, "atk_text_get_run_attributes", "offset");
489       test_int = string_to_int(param_string1);
490       attrib = atk_text_get_run_attributes(ATK_TEXT(obj), test_int, &start, &end);
491       sprintf(output, "get_run_attributes at offset %i:\nStart: %i, End: %i\n", test_int,
492         start, end);
493       set_output_buffer(output);
494       if (attrib != NULL) {
495         GSList *node;
496         index = 0;
497         node = attrib;
498         while (node != NULL)
499         {
500           AtkAttribute* att = node->data;
501
502           sprintf(output, "List index: %i, Name: %s, Value: %s\n", index,
503             att->name, att->value);
504           set_output_buffer(output);
505           node = node->next;
506           index++;
507         }
508         atk_attribute_set_free (attrib);
509       }
510     }
511
512     if (strcmp(testsOn[i], "atk_text_get_default_attributes") == 0)
513     {
514       attrib = atk_text_get_default_attributes(ATK_TEXT(obj));
515       sprintf(output, "get_default_attributes\n");
516       set_output_buffer(output);
517       if (attrib != NULL) {
518         GSList *node;
519         index = 0;
520         node = attrib;
521         while (node != NULL)
522         {
523           AtkAttribute* att = node->data;
524
525           sprintf(output, "List index: %i, Name: %s, Value: %s\n", index,
526             att->name, att->value);
527           set_output_buffer(output);
528           node = node->next;
529           index++;
530         }
531         atk_attribute_set_free (attrib);
532       }
533     }
534  
535     if (strcmp(testsOn[i], "atk_text_get_character_extents") == 0)
536     {
537       gint test_int;
538       param_string1 = get_arg_of_func(win_val, "atk_text_get_character_extents",
539         "offset");
540       param_string2 = get_arg_of_func(win_val, "atk_text_get_character_extents",
541         "coord mode");
542       test_int = string_to_int(param_string1);
543       if (strcmp(param_string2, "ATK_XY_SCREEN") == 0)
544       {
545         atk_text_get_character_extents(ATK_TEXT(obj), test_int, &x, &y, &width,
546           &height, ATK_XY_SCREEN);   
547         sprintf(output,
548           "get_character_extents at offset %i, mode: SCREEN\nX: %i, Y: %i, width: %i, height: %i\n",
549           test_int, x, y, width, height);
550       }
551       else if (strcmp(param_string2, "ATK_XY_WINDOW") == 0)
552       {
553         atk_text_get_character_extents(ATK_TEXT(obj), test_int, &x, &y, &width,
554           &height, ATK_XY_WINDOW);
555         sprintf(output,
556           "get_character_extents at offset %i, mode: WIDGET_WINDOW\nX: %i, Y: %i, width: %i, height: %i\n",
557           test_int, x, y, width, height);
558       }
559       else
560         sprintf(output, "get_character_extents_at_offset: Invalid coord mode argument!");
561            
562       set_output_buffer(output);
563     } 
564
565     if (strcmp(testsOn[i], "atk_text_get_offset_at_point") == 0)
566     {
567       gint test_int;
568       param_string1 = get_arg_of_func(win_val, "atk_text_get_offset_at_point", "x");
569       param_string2 = get_arg_of_func(win_val, "atk_text_get_offset_at_point", "y");
570       param_string3 = get_arg_of_func(win_val, "atk_text_get_offset_at_point", "coord mode");
571       param_int1 = string_to_int(param_string1);
572       param_int2 = string_to_int(param_string2);
573       if (strcmp(param_string3, "ATK_XY_SCREEN") == 0)
574       {
575         test_int = atk_text_get_offset_at_point(ATK_TEXT(obj), param_int1, param_int2,
576           ATK_XY_SCREEN);   
577         if (test_int != -1)
578           sprintf(output, "get_offset_at_point %i,%i mode: SCREEN is %i\n", param_int1, param_int2, test_int);
579         else 
580           sprintf(output, "Cannot get_offset_at_point\n");
581       }
582       else if (strcmp(param_string3, "ATK_XY_WINDOW") == 0)
583       {
584         test_int = atk_text_get_offset_at_point(ATK_TEXT(obj), param_int1, param_int2,
585           ATK_XY_WINDOW);   
586         if (test_int != -1)
587           sprintf(output, "get_offset_at_point %i,%i mode: WIDGET_WINDOW is %i\n", param_int1, param_int2, test_int);
588         else
589           sprintf(output, "Cannot get_offset_at_point\n");
590       }
591       else
592         sprintf(output, "get_offset_at_point: Invalid coord mode argument!");
593            
594       set_output_buffer(output);
595     } 
596     if (ATK_IS_EDITABLE_TEXT(obj))
597     {
598       if (strcmp(testsOn[i], "atk_editable_text_set_run_attributes") == 0)
599       {
600         param_string1 = get_arg_of_func(win_val,
601           "atk_editable_text_set_run_attributes", "start");
602         param_string2 = get_arg_of_func(win_val,
603           "atk_editable_text_set_run_attributes", "end");
604         result = atk_editable_text_set_run_attributes(ATK_EDITABLE_TEXT(obj),
605           attrib, string_to_int(param_string1), string_to_int(param_string2));
606         if (result)
607           sprintf(output, "\nSetting attributes in range %d to %d...OK\n",
608             string_to_int(param_string1), string_to_int(param_string2));
609         else
610           sprintf(output, "\nSetting attributes in range %d to %d...Failed\n",
611             string_to_int(param_string1), string_to_int(param_string2));
612         set_output_buffer(output); 
613       }
614       
615       if (strcmp(testsOn[i], "atk_editable_text_cut_text") == 0)
616       {
617         param_string1 = get_arg_of_func(win_val, "atk_editable_text_cut_text", "start");
618         param_string2 = get_arg_of_func(win_val, "atk_editable_text_cut_text", "end");
619         atk_editable_text_cut_text(ATK_EDITABLE_TEXT(obj),
620           string_to_int(param_string1), string_to_int(param_string2));
621         sprintf(output, "\nCutting text %d to %d...\n",
622           string_to_int(param_string1), string_to_int(param_string2));
623         set_output_buffer(output); 
624       }
625       
626       if (strcmp(testsOn[i], "atk_editable_text_paste_text") == 0)
627       {
628         param_string1 = get_arg_of_func(win_val, "atk_editable_text_paste_text",
629           "position");
630         atk_editable_text_paste_text(ATK_EDITABLE_TEXT(obj),
631           string_to_int(param_string1));
632         sprintf(output, "\nPasting text to %d\n", string_to_int(param_string1));
633         set_output_buffer(output); 
634       }
635       
636       if (strcmp(testsOn[i], "atk_editable_text_delete_text") == 0)
637       {
638         param_string1 = get_arg_of_func(win_val, "atk_editable_text_delete_text", "start");
639         param_string2 = get_arg_of_func(win_val, "atk_editable_text_delete_text", "end");
640         atk_editable_text_delete_text(ATK_EDITABLE_TEXT(obj),
641           string_to_int(param_string1), string_to_int(param_string2));
642         sprintf(output, "\nDeleting text %d to %d...\n",
643           string_to_int(param_string1), string_to_int(param_string2));
644         set_output_buffer(output); 
645       }
646       
647       if (strcmp(testsOn[i], "atk_editable_text_copy_text") == 0)
648       {
649         param_string1 = get_arg_of_func(win_val, "atk_editable_text_copy_text", "start");
650         param_string2 = get_arg_of_func(win_val, "atk_editable_text_copy_text", "end");
651         atk_editable_text_copy_text(ATK_EDITABLE_TEXT(obj),
652           string_to_int(param_string1), string_to_int(param_string2));
653         sprintf(output, "\nCopying text %d to %d...\n",
654           string_to_int(param_string1), string_to_int(param_string2));
655         set_output_buffer(output); 
656       }
657       
658       if (strcmp(testsOn[i], "atk_editable_text_insert_text") == 0)
659       {
660         param_string1 = get_arg_of_func(win_val, "atk_editable_text_insert_text",
661           "insert text");
662         param_string2 = get_arg_of_func(win_val, "atk_editable_text_insert_text",
663           "position");
664         param_int2 = string_to_int(param_string2);
665         atk_editable_text_insert_text(ATK_EDITABLE_TEXT(obj),
666           param_string1, strlen(param_string1), &param_int2);
667         sprintf(output, "\nInserting text at %d...\n", param_int2);
668         set_output_buffer(output); 
669       }
670     }
671   }  
672 }
673
674 /**
675  * _run_offset_test:
676  * @obj: An #AtkObject
677  * @type: The type of test to run.  Can be "at", "before", or "after".
678  * @offset: The offset into the text buffer.
679  * @boundary: The boundary type.
680  *
681  * Tests the following ATK_TEXT API functions:
682  * atk_text_get_text_at_offset
683  * atk_text_get_text_before_offseet
684  * atk_text_get_text_after_offset
685  **/
686 void _run_offset_test(AtkObject * obj, char * type, gint offset,
687   AtkTextBoundary boundary)
688 {
689   gchar output[MAX_LINE_SIZE];
690   gchar default_val[5] = "NULL";
691   gchar *text;
692   gint  startOffset, endOffset;
693
694   if (strcmp(type, "at") == 0)
695     text = atk_text_get_text_at_offset (ATK_TEXT (obj),
696        offset, boundary, &startOffset, &endOffset);
697   else if (strcmp(type, "before") == 0)
698     text = atk_text_get_text_before_offset (ATK_TEXT (obj),
699        offset, boundary, &startOffset, &endOffset);
700   else if (strcmp(type, "after") == 0)
701     text = atk_text_get_text_after_offset (ATK_TEXT (obj),
702        offset, boundary, &startOffset, &endOffset);
703   else
704     text = NULL;
705
706   if (text == NULL)
707     text = g_strdup (default_val);
708     
709   if (boundary == ATK_TEXT_BOUNDARY_CHAR)
710     sprintf(output, "\n|%s| Text |%s|  Boundary |BOUNDARY_CHAR|\n",
711       type, text);
712   else if (boundary == ATK_TEXT_BOUNDARY_WORD_START)
713     sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_WORD_START|\n",
714       type, text);
715   else if (boundary == ATK_TEXT_BOUNDARY_WORD_END)
716     sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_WORD_END|\n",
717       type, text);
718   else if (boundary == ATK_TEXT_BOUNDARY_SENTENCE_START)
719     sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_SENTENCE_START|\n",
720       type, text);
721   else if (boundary == ATK_TEXT_BOUNDARY_SENTENCE_END)
722     sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_SENTENCE_END|\n",
723       type, text);
724   else if (boundary == ATK_TEXT_BOUNDARY_LINE_START)
725     sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_LINE_START|\n",
726       type, text);
727   else if (boundary == ATK_TEXT_BOUNDARY_LINE_END)
728     sprintf(output, "\n|%s| Text |%s| Boundary |BOUNDARY_LINE_END|\n",
729       type, text);
730   else
731     sprintf(output, "\n|%s| Text |%s| Boundary |UNKNOWN|\n",
732       type, text);
733
734   g_free (text);  
735   set_output_buffer(output);
736
737   sprintf(output, "Offset %d, startOffset %d, endOffset %d\n",
738     offset, startOffset, endOffset);
739   set_output_buffer(output);
740 }