1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Linux Desktop Testing Project http://ldtp.freedesktop.org
*
* Author:
* Poornima Nayak<pnayak@novell.com>
* Nagappan Alagappan <nagappan@gmail.com>
* Veerapuram Varadhan <v.varadhan@gmail.com>
*
* Copyright 2004 - 2006 Novell, Inc.
* Copyright 2007 - 2008 Nagappan Alagappan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110, USA.
*/
#include "ldtp.h"
#include "ldtp-gui.h"
#include "ldtp-error.h"
#include "ldtp-utils.h"
#include "ldtp-logger.h"
#include "ldtp-command.h"
#include "ldtp-gui-comp.h"
static LDTPErrorCode
click (Accessible *object, FILE *log_fp)
{
SPIBoolean flag = FALSE;
AccessibleAction *action;
if (wait_till_object_state_contains (object, COMBO_BOX, log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", log_fp);
return LDTP_ERROR_CLICK_FAILED;
}
action = Accessible_getAction (object);
flag = AccessibleAction_doAction (action, 0);
Accessible_unref (action);
if (flag)
return LDTP_ERROR_SUCCESS;
else
return LDTP_ERROR_CLICK_FAILED;
}
static gboolean
get_state_visible (Accessible *object)
{
SPIBoolean visible = FALSE;
AccessibleStateSet *state;
state = Accessible_getStateSet (object);
if (state)
visible = AccessibleStateSet_contains (state, SPI_STATE_VISIBLE);
if (visible)
return TRUE;
else
return FALSE;
}
static LDTPErrorCode
hide_list (Accessible *object, FILE *log_fp)
{
int type;
SPIBoolean flag = FALSE;
Accessible *hide_object;
AccessibleAction *action;
if (wait_till_object_state_contains (object, COMBO_BOX, log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", log_fp);
return LDTP_ERROR_HIDELIST_FAILED;
}
type = get_child_object_type (object);
if (type == SPI_ROLE_LIST) {
hide_object = get_list_handle (object);
if (get_state_visible (hide_object) == FALSE) {
/*
If object is already in hidden state, we can't proceed hiding the object.
*/
log_msg (LDTP_LOG_WARNING, "List already in hidden state", log_fp);
Accessible_unref (hide_object);
return LDTP_ERROR_SUCCESS;
}
action = Accessible_getAction (hide_object);
if (action) {
flag = AccessibleAction_doAction (action, 0);
Accessible_unref (action);
}
Accessible_unref (hide_object);
} else if (type == SPI_ROLE_MENU) {
hide_object = get_menu_handle (object);
if (get_state_visible (hide_object) == FALSE) {
/*
If object is already in hidden state, we can't proceed hiding the object.
*/
log_msg (LDTP_LOG_WARNING, "Menu already in hidden state", log_fp);
Accessible_unref (hide_object);
return LDTP_ERROR_SUCCESS;
}
action = Accessible_getAction (object);
if (action) {
flag = AccessibleAction_doAction (action, 0);
Accessible_unref (action);
}
Accessible_unref (hide_object);
}
if (flag)
return LDTP_ERROR_SUCCESS;
else
return LDTP_ERROR_HIDELIST_FAILED;
}
static LDTPErrorCode
show_list (Accessible *object, FILE *log_fp)
{
int type;
SPIBoolean flag = FALSE;
Accessible *show_object;
AccessibleAction *action;
if (wait_till_object_state_contains (object, COMBO_BOX, log_fp) != 0) {
g_print ("Not all combo box object properties enabled\n");
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", log_fp);
return LDTP_ERROR_SHOWLIST_FAILED;
}
type = get_child_object_type (object);
if (type == SPI_ROLE_LIST) {
show_object = get_list_handle (object);
if (get_state_visible (show_object) == TRUE) {
/*
If object is already in visible state, we can't proceed with this step.
*/
log_msg (LDTP_LOG_WARNING, "List already in visible state", log_fp);
Accessible_unref (show_object);
return LDTP_ERROR_SUCCESS;
}
action = Accessible_getAction (show_object);
if (action) {
flag = AccessibleAction_doAction (action, 0);
Accessible_unref (action);
}
Accessible_unref (show_object);
}
if (type == SPI_ROLE_MENU) {
show_object = get_menu_handle (object);
if (get_state_visible (show_object) == TRUE) {
/*
If object is already in visible state, we can't proceed with this step.
*/
log_msg (LDTP_LOG_WARNING, "Menu already in visible state", log_fp);
Accessible_unref (show_object);
return LDTP_ERROR_SUCCESS;
}
action = Accessible_getAction (object);
if (action) {
flag = AccessibleAction_doAction (action, 0);
Accessible_unref (action);
}
Accessible_unref (show_object);
}
g_print ("Flag: %d\n", flag);
if (flag)
return LDTP_ERROR_SUCCESS;
else
return LDTP_ERROR_SHOWLIST_FAILED;
}
static LDTPErrorCode
select_item (LDTPClientContext* cctxt)
{
int type, count, i;
LDTPErrorCode error;
char *name = NULL;
Accessible *object = cctxt->gui_handle->handle;
Accessible *text = NULL;
Accessible *child = NULL;
Accessible *menu_object = NULL;
char msg [256];
if (wait_till_object_state_contains (object, COMBO_BOX, cctxt->log_fp) != 0) {
g_print ("Not all combo box object properties enabled\n");
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", cctxt->log_fp);
return LDTP_ERROR_SELECTITEM_FAILED;
}
type = get_child_object_type (object);
g_print ("Object type: %d\n", type);
if (type == SPI_ROLE_LIST) {
child = get_list_handle (object);
if (child) {
cctxt->gui_handle->handle = child;
error = list_main (cctxt, LDTP_CMD_SELECTTEXTITEM);
Accessible_unref (child);
cctxt->gui_handle->handle = object;
if (error != LDTP_ERROR_SUCCESS) {
g_print ("Combo box SelectItem action failed\n");
log_msg (LDTP_LOG_CAUSE, "Combo box SelectItem action failed", cctxt->log_fp);
return LDTP_ERROR_SELECTITEM_FAILED;
}
}
text = get_text_handle (object);
if (text) {
cctxt->gui_handle->handle = text;
error = text_main (cctxt, LDTP_CMD_VERIFYSETTEXT);
Accessible_unref (text);
cctxt->gui_handle->handle = object;
if (error == LDTP_ERROR_SUCCESS)
return LDTP_ERROR_SUCCESS;
}
g_print ("Combo box select verify action failed\n");
log_msg (LDTP_LOG_CAUSE, "Combo box select verify action failed", cctxt->log_fp);
return LDTP_ERROR_VERIFY_SETTEXTVALUE_FAILED;
} else if (type == SPI_ROLE_MENU) {
menu_object = get_menu_handle (object);
if (menu_object == NULL) {
g_sprintf (msg, "Combobox: %s item does not exist\n",
(char *)cctxt->req->arg_list->data);
log_msg (LDTP_LOG_CAUSE, msg, cctxt->log_fp);
return LDTP_ERROR_ITEM_NOT_FOUND;
}
count = Accessible_getChildCount (menu_object);
for (i = 0; i < count; i++) {
child = Accessible_getChildAtIndex (menu_object, i);
if (child) {
char *tmp = NULL;
name = Accessible_getName (child);
g_print ("Combobox - name: %s - param: %s\n",
name, (char *) cctxt->req->arg_list->data);
if (g_utf8_strchr (name, -1, ' ') != NULL)
tmp = escape_character (name, ' ');
/*
FIXME: Use g_utf8_*
*/
if (strcasecmp (name, cctxt->req->arg_list->data) == 0 ||
(tmp && strcasecmp (tmp, cctxt->req->arg_list->data) == 0)) {
free (tmp);
SPI_freeString (name);
cctxt->gui_handle->handle = child;
error = menu_item_main (cctxt, LDTP_CMD_SELECTMENUITEM);
Accessible_unref (menu_object);
Accessible_unref (child);
cctxt->gui_handle->handle = object;
if (error != LDTP_ERROR_SUCCESS) {
g_print ("Combo Box: SelectItem action failed\n");
log_msg (LDTP_LOG_CAUSE, "Combo Box: SelectItem action failed", cctxt->log_fp);
return LDTP_ERROR_SELECTITEM_FAILED;
} else {
return LDTP_ERROR_SUCCESS;
}
}
g_free (tmp);
SPI_freeString (name);
Accessible_unref (child);
} // if
} // for
Accessible_unref (menu_object);
cctxt->gui_handle->handle = object;
g_sprintf (msg, "Combobox: %s item does not exist\n",
(char *)cctxt->req->arg_list->data);
log_msg (LDTP_LOG_CAUSE, msg, cctxt->log_fp);
return LDTP_ERROR_ITEM_NOT_FOUND;
}
g_print ("Verify combo box click child type is unidentified\n");
log_msg (LDTP_LOG_CAUSE, "Verify combo box click child type is unidentified", cctxt->log_fp);
return LDTP_ERROR_CHILD_TYPE_UNIDENTIFIED;
}
static LDTPErrorCode
capture_to_file (Accessible *object, char *file_name, FILE *log_fp)
{
int type;
long count, i;
long child_count;
char *name;
FILE *fp = NULL;
Accessible *child, *menu_object;
Accessible *child_object, *child_text;
if (file_name)
fp = fopen (file_name, "w");
else
fp = fopen ("comboboxitem.lst", "w");
if (fp == NULL) {
log_msg (LDTP_LOG_CAUSE, "Combo box: Cannot open output file", log_fp);
return LDTP_ERROR_FILECAPTURE_FAILED_OPEN_OUTPUT_FILE;
}
if (wait_till_object_state_contains (object, COMBO_BOX, log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Combo Box: SelectItem action failed", log_fp);
return LDTP_ERROR_SELECTITEM_FAILED;
}
type = get_child_object_type (object);
g_print ("Object type: %d\n", type);
if (type == SPI_ROLE_LIST) {
child = get_list_handle (object);
if (child != NULL) {
child_count = Accessible_getChildCount (child);
for (i = 0; i < child_count; i++) {
child_object = Accessible_getChildAtIndex (child, i);
child_text = Accessible_getText (child_object);
name = AccessibleText_getText (child_text, 0, LONG_MAX);
g_print ("Item-ID: %ld -- NAME: %s\n", i, name);
g_fprintf (fp, "%s\n", name);
SPI_freeString (name);
Accessible_unref (child_text);
Accessible_unref (child_object);
}
}
Accessible_unref (child);
} else if (type == SPI_ROLE_MENU) {
menu_object = get_menu_handle (object);
if (menu_object) {
count = Accessible_getChildCount (menu_object);
if (count > 0) {
for (i = 0; i < count; i++) {
child = Accessible_getChildAtIndex (menu_object, i);
if (child) {
name = Accessible_getName (child);
g_print ("Item-ID: %ld -- NAME: %s\n", i, name);
g_fprintf (fp, "%s\n", name);
SPI_freeString (name);
Accessible_unref (child);
}
}
Accessible_unref (menu_object);
}
}
} else {
fclose (fp);
log_msg (LDTP_LOG_CAUSE, "Verify combo box click child type is unidentified", log_fp);
return LDTP_ERROR_CHILD_TYPE_UNIDENTIFIED;
}
fclose (fp);
return LDTP_ERROR_SUCCESS;
}
static LDTPErrorCode
select_index (LDTPClientContext* cctxt)
{
LDTPErrorCode error;
Accessible *child;
Accessible *object = cctxt->gui_handle->handle;
if (wait_till_object_state_contains (object, COMBO_BOX, cctxt->log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", cctxt->log_fp);
return LDTP_ERROR_SELECTINDEX_FAILED;
}
child = get_list_handle (object);
if (child) {
cctxt->gui_handle->handle = child;
error = list_main (cctxt, LDTP_CMD_SELECTINDEX);
Accessible_unref (child);
cctxt->gui_handle->handle = object;
if (error != LDTP_ERROR_SUCCESS) {
log_msg (LDTP_LOG_CAUSE, "Combo Box: SelectIndex action failed", cctxt->log_fp);
error = LDTP_ERROR_SELECTINDEX_FAILED;
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), cctxt->log_fp);
return error;
}
} else {
error = LDTP_ERROR_SELECTINDEX_FAILED;
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), cctxt->log_fp);
return error;
}
return LDTP_ERROR_SUCCESS;
}
static LDTPErrorCode
set_text_value (LDTPClientContext* cctxt)
{
Accessible *text_obj;
LDTPErrorCode error;
Accessible *object = cctxt->gui_handle->handle;
if (wait_till_object_state_contains (object, COMBO_BOX, cctxt->log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", cctxt->log_fp);
return LDTP_ERROR_SETTEXTVALUE_FAILED;
}
if (!cctxt->req->arg_list->data) {
error = LDTP_ERROR_SETTEXTVALUE_FAILED;
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), cctxt->log_fp);
return error;
}
text_obj = get_text_handle (object);
if (!text_obj) {
error = LDTP_ERROR_SETTEXTVALUE_FAILED;
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), cctxt->log_fp);
return error;
}
cctxt->gui_handle->handle = text_obj;
error = text_main (cctxt, LDTP_CMD_SETTEXTVALUE);
if (error != LDTP_ERROR_SUCCESS) {
Accessible_unref (text_obj);
cctxt->gui_handle->handle = object;
log_msg (LDTP_LOG_CAUSE, "Combo Box: SetTextValue action failed during setting", cctxt->log_fp);
return LDTP_ERROR_SETTEXTVALUE_FAILED;
}
error = text_main (cctxt, LDTP_CMD_VERIFYSETTEXT);
if (error != LDTP_ERROR_SUCCESS) {
Accessible_unref (text_obj);
cctxt->gui_handle->handle = object;
log_msg (LDTP_LOG_CAUSE, "Combo Box: SetTextValue verify action failed during verifying", cctxt->log_fp);
return LDTP_ERROR_VERIFY_SETTEXTVALUE_FAILED;
}
Accessible_unref (text_obj);
cctxt->gui_handle->handle = object;
return LDTP_ERROR_SUCCESS;
}
static LDTPErrorCode
verify_drop_down (Accessible *object, FILE *log_fp)
{
int focused, child_type;
int showing, visible;
Accessible *child_object;
AccessibleStateSet *state;
if (wait_till_object_state_contains (object, COMBO_BOX, log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", log_fp);
return LDTP_ERROR_CLICK_FAILED;
}
child_type = get_child_object_type (object);
if (child_type == SPI_ROLE_LIST) {
child_object = (Accessible *) get_list_handle (object);
if (child_object) {
state = Accessible_getStateSet (object);
focused = AccessibleStateSet_contains (state, SPI_STATE_FOCUSABLE);
Accessible_unref (child_object);
if (focused == 0) {
log_msg (LDTP_LOG_CAUSE, "Verify Combo box list child is not focused", log_fp);
return LDTP_ERROR_CHILD_NOT_FOCUSSED;
} else
return LDTP_ERROR_SUCCESS;
}
} else if (child_type == SPI_ROLE_MENU) {
child_object = (Accessible *) get_menu_handle (object);
if (child_object) {
state = Accessible_getStateSet (object);
showing = AccessibleStateSet_contains (state, SPI_STATE_SHOWING);
visible = AccessibleStateSet_contains (state, SPI_STATE_VISIBLE);
Accessible_unref (child_object);
if ((showing == 0) && (visible == 0)) {
log_msg (LDTP_LOG_CAUSE, "Verify combo box menu child is not showing", log_fp);
return LDTP_ERROR_MENU_NOT_VISIBLE;
} else
return LDTP_ERROR_SUCCESS;
}
} else {
log_msg (LDTP_LOG_CAUSE, "Verify combo box click child type is unidentified", log_fp);
return LDTP_ERROR_CHILD_TYPE_UNIDENTIFIED;
}
return LDTP_ERROR_VERIFY_DROPDOWN_FAILED;
}
static LDTPErrorCode
verify_hide_list (Accessible *object, FILE *log_fp)
{
int child_type;
Accessible *child_object;
AccessibleStateSet *state;
SPIBoolean visible;
SPIBoolean showing;
SPIBoolean focused;
if (wait_till_object_state_contains (object, COMBO_BOX, log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", log_fp);
return LDTP_ERROR_CLICK_FAILED;
}
child_type = get_child_object_type (object);
if (child_type == SPI_ROLE_LIST) {
child_object = get_list_handle (object);
if (child_object) {
state = Accessible_getStateSet (object);
focused = AccessibleStateSet_contains (state, SPI_STATE_FOCUSABLE);
Accessible_unref (child_object);
if (focused == TRUE) {
log_msg (LDTP_LOG_CAUSE, "Verify Combo box list child is focused", log_fp);
return LDTP_ERROR_CHILD_IN_FOCUS;
}
return LDTP_ERROR_SUCCESS;
}
}
else if (child_type == SPI_ROLE_MENU) {
child_object = get_menu_handle (object);
if (child_object) {
state = Accessible_getStateSet (object);
showing = AccessibleStateSet_contains (state, SPI_STATE_SHOWING);
visible = AccessibleStateSet_contains (state, SPI_STATE_VISIBLE);
Accessible_unref (child_object);
if (showing == FALSE && visible == FALSE) {
/* Varadhan
Are we checking for visibility or invisibility?
*/
log_msg (LDTP_LOG_CAUSE, "Verify combo box menu child is showing & visible", log_fp);
return LDTP_ERROR_MENU_VISIBLE;
}
return LDTP_ERROR_SUCCESS;
}
}
log_msg (LDTP_LOG_CAUSE, "Verify combo box hidelist child type is unidentified", log_fp);
return LDTP_ERROR_CHILD_TYPE_UNIDENTIFIED;
}
static LDTPErrorCode
verify_show_list (Accessible *object, FILE *log_fp)
{
if (verify_drop_down (object, log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Verify combo box showlist action failed", log_fp);
return LDTP_ERROR_VERIFY_SHOWLIST_FAILED;
}
else
return LDTP_ERROR_SUCCESS;
}
static LDTPErrorCode
verify_set_text_value (LDTPClientContext* cctxt)
{
int child_type;
LDTPErrorCode error;
Accessible *text_object;
Accessible *object = cctxt->gui_handle->handle;
child_type = get_child_object_type (object);
if (child_type == SPI_ROLE_LIST) {
if (wait_till_object_state_contains (object, COMBO_BOX, cctxt->log_fp) != 0) {
g_print ("Verify Combo box SetTextValue action failed\n");
log_msg (LDTP_LOG_CAUSE, "Verify Combo box SetTextValue action failed", cctxt->log_fp);
return LDTP_ERROR_VERIFY_SETTEXTVALUE_FAILED;
}
text_object = get_text_handle (object);
if (text_object) {
cctxt->gui_handle->handle = text_object;
error = text_main (cctxt, LDTP_CMD_VERIFYSETTEXT);
Accessible_unref (text_object);
cctxt->gui_handle->handle = object;
if (error != LDTP_ERROR_SUCCESS) {
g_print ("Verify Combo box SetTextValue action failed\n");
log_msg (LDTP_LOG_CAUSE, "Verify Combo box SetTextValue action failed", cctxt->log_fp);
return LDTP_ERROR_VERIFY_SETTEXTVALUE_FAILED;
}
return LDTP_ERROR_SUCCESS;
} else {
g_print ("Verify Combo box SetTextValue child object is NULL\n");
log_msg (LDTP_LOG_CAUSE, "Verify Combo box SetTextValue child object is NULL", cctxt->log_fp);
return LDTP_ERROR_VERIFY_SETTEXTVALUE_FAILED;
}
} else if (child_type == SPI_ROLE_MENU) {
gboolean flag = FALSE;
char *name = Accessible_getName (object);
if (name) {
if (cctxt && cctxt->req && cctxt->req->arg_list &&
cctxt->req->arg_list->data &&
(g_utf8_collate (cctxt->req->arg_list->data, name) == 0)) {
g_print ("Name: %s - %s\n", name, (char *)cctxt->req->arg_list->data);
flag = TRUE;
}
SPI_freeString (name);
}
if (flag)
return LDTP_ERROR_SUCCESS;
else {
g_print ("Ldtp error verify settextvalue failed\n");
return LDTP_ERROR_VERIFY_SETTEXTVALUE_FAILED;
}
}
g_print ("Object type not matched: Ldtp error verify settextvalue failed\n");
return LDTP_ERROR_VERIFY_SETTEXTVALUE_FAILED;
}
static LDTPErrorCode
verify_select_item (LDTPClientContext* cctxt)
{
LDTPErrorCode error;
error = verify_set_text_value (cctxt);
if (error != LDTP_ERROR_SUCCESS) {
g_print ("verify combo box select action failed\n");
log_msg (LDTP_LOG_CAUSE, "verify combo box select action failed", cctxt->log_fp);
return LDTP_ERROR_VERIFY_ITEM_FAILED;
}
return LDTP_ERROR_SUCCESS;
}
static LDTPErrorCode
combo_select_index (LDTPClientContext* cctxt, int index)
{
int type;
long count;
Accessible *child, *menu_object;
Accessible *object = cctxt->gui_handle->handle;
if (wait_till_object_state_contains (object, COMBO_BOX, cctxt->log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", cctxt->log_fp);
return LDTP_ERROR_SELECTITEM_FAILED;
}
type = get_child_object_type (object);
if (type == SPI_ROLE_MENU) {
menu_object = get_menu_handle (object);
if (menu_object) {
count = Accessible_getChildCount (menu_object);
if (count > 0) {
child = Accessible_getChildAtIndex (menu_object, index);
Accessible_unref (menu_object);
if (child) {
LDTPErrorCode error;
cctxt->gui_handle->handle = child;
error = menu_item_main (cctxt, LDTP_CMD_SELECTMENUITEM);
cctxt->gui_handle->handle = object;
Accessible_unref (child);
if (error != LDTP_ERROR_SUCCESS) {
log_msg (LDTP_LOG_CAUSE, "Combo Box: SelectItem action failed", cctxt->log_fp);
return LDTP_ERROR_SELECTITEM_FAILED;
}
else
return LDTP_ERROR_SUCCESS;
}
}// if
else
Accessible_unref (menu_object);
}
log_msg (LDTP_LOG_CAUSE, "Combo Box: SelectItem does not exist in", cctxt->log_fp);
/*
Varadhan
FIXME: Item does not exist or action failed?
*/
return LDTP_ERROR_SELECTITEM_FAILED;
}
/* Varadhan
FIXME: More specific error should be returned
*/
log_msg (LDTP_LOG_CAUSE, "Verify combo box click child type is unidentified", cctxt->log_fp);
return LDTP_ERROR_SELECTITEM_FAILED;
}
static LDTPErrorCode
get_text_value (LDTPClientContext* cctxt)
{
int type;
long child_count, i;
Accessible *child;
char *item = NULL;
AccessibleRole role;
Accessible *object = cctxt->gui_handle->handle;
if (wait_till_object_state_contains (object, COMBO_BOX, cctxt->log_fp) != 0) {
log_msg (LDTP_LOG_CAUSE, "Not all combo box object properties enabled", cctxt->log_fp);
return LDTP_ERROR_GETTEXTVALUE_FAILED;
}
type = get_child_object_type (object);
if (type == SPI_ROLE_LIST) {
child = NULL;
child_count = Accessible_getChildCount (object);
for (i = 0; i < child_count; i++) {
child = Accessible_getChildAtIndex (object, i);
role = Accessible_getRole (child);
if (role == SPI_ROLE_TEXT)
break;
else {
Accessible_unref (child);
child = NULL;
}
}
if (child) {
LDTPErrorCode error;
cctxt->req->arg_list = g_slist_prepend (cctxt->req->arg_list,
"0");
cctxt->req->arg_list = g_slist_prepend (cctxt->req->arg_list,
"0");
cctxt->gui_handle->handle = child;
error = text_main (cctxt, LDTP_CMD_GETTEXTVALUE);
cctxt->req->arg_list = g_slist_remove (cctxt->req->arg_list, "0");
cctxt->req->arg_list = g_slist_remove (cctxt->req->arg_list, "0");
cctxt->gui_handle->handle = object;
Accessible_unref (child);
if (error != LDTP_ERROR_SUCCESS) {
log_msg (LDTP_LOG_CAUSE,
"Combo box gettextvalue action failed",
cctxt->log_fp);
return LDTP_ERROR_GETTEXTVALUE_FAILED;
}
cctxt->resp->data_len = g_utf8_strlen (cctxt->req->arg_list->data, -1);
cctxt->resp->data = g_strdup (cctxt->req->arg_list->data);
cctxt->req->arg_list = g_slist_remove (cctxt->req->arg_list->data, cctxt->resp->data);
return LDTP_ERROR_SUCCESS;
} else {
log_msg (LDTP_LOG_CAUSE,
"Combo box gettextvalue action failed",
cctxt->log_fp);
return LDTP_ERROR_GETTEXTVALUE_FAILED;
}
} else if (type == SPI_ROLE_MENU) {
child = Accessible_getText (object);
item = AccessibleText_getText (child, 0, LONG_MAX);
cctxt->resp->data = g_strdup (item);
cctxt->resp->data_len = AccessibleText_getCharacterCount (child);
SPI_freeString (item);
Accessible_unref (child);
return LDTP_ERROR_SUCCESS;
} else {
log_msg (LDTP_LOG_CAUSE, "Combo box child type is unidentified", cctxt->log_fp);
return LDTP_ERROR_CHILD_TYPE_UNIDENTIFIED;
}
}
LDTPErrorCode
combo_box_main (LDTPClientContext* cctxt, int command)
{
LDTPErrorCode error;
switch (command) {
case LDTP_CMD_CLICK:
error = click (cctxt->gui_handle->handle, cctxt->log_fp);
break;
case LDTP_CMD_HIDELIST:
error = hide_list (cctxt->gui_handle->handle, cctxt->log_fp);
break;
case LDTP_CMD_COMBOSELECT:
error = select_item (cctxt);
break;
case LDTP_CMD_SELECTINDEX:
error = select_index (cctxt);
break;
case LDTP_CMD_SETTEXTVALUE:
error = set_text_value (cctxt);
break;
case LDTP_CMD_SHOWLIST:
error = show_list (cctxt->gui_handle->handle, cctxt->log_fp);
break;
case LDTP_CMD_VERIFYDROPDOWN:
error = verify_drop_down (cctxt->gui_handle->handle, cctxt->log_fp);
break;
case LDTP_CMD_VERIFYHIDELIST:
error = verify_hide_list (cctxt->gui_handle->handle, cctxt->log_fp);
break;
case LDTP_CMD_VERIFYSHOWLIST:
error = verify_show_list (cctxt->gui_handle->handle, cctxt->log_fp);
break;
case LDTP_CMD_VERIFYSELECT:
error = verify_select_item (cctxt);
break;
case LDTP_CMD_VERIFYSETTEXT:
error = verify_set_text_value (cctxt);
break;
case LDTP_CMD_COMBOSELECTINDEX: {
long index = 0;
if (cctxt->req->arg_list && cctxt->req->arg_list->data)
index = atol (cctxt->req->arg_list->data);
error = combo_select_index (cctxt, index);
break;
}
case LDTP_CMD_CAPTURETOFILE: {
char *filename = NULL;
if (cctxt->req->arg_list && cctxt->req->arg_list->data)
filename = cctxt->req->arg_list->data;
error = capture_to_file (cctxt->gui_handle->handle,
filename, cctxt->log_fp);
break;
}
case LDTP_CMD_GETTEXTVALUE:
error = get_text_value (cctxt);
break;
case LDTP_CMD_KBDENTER:
error = device_main (cctxt, command);
break;
case LDTP_CMD_GETOBJECTSIZE:
cctxt->resp->data_len = 0;
cctxt->resp->data = get_size (cctxt->gui_handle->handle, &error);
if (cctxt->resp->data) {
cctxt->resp->data_len = g_utf8_strlen (cctxt->resp->data, -1);
}
break;
default:
error = LDTP_ERROR_COMMAND_NOT_IMPLEMENTED;
}
return error;
}
|