1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
3
* Linux Desktop Testing Project http://ldtp.freedesktop.org
6
* Nagappan Alagappan <nagappan@gmail.com>
7
* Poornima <pnayak@novell.com>
9
* Copyright 2004 - 2006 Novell, Inc.
10
* Copyright 2007 - 2008 Nagappan Alagappan
12
* This program is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU Lesser General Public
14
* License as published by the Free Software Foundation; either
15
* version 2 of the License, or (at your option) any later version.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
* Lesser General Public License for more details.
22
* You should have received a copy of the GNU Lesser General Public
23
* License along with this program; if not, write to the
24
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25
* Boston, MA 02110, USA.
30
#include "ldtp-error.h"
31
#include "ldtp-logger.h"
32
#include "ldtp-command.h"
33
#include "ldtp-gui-comp.h"
36
Get the check box state of the given object
39
get_check_box_state (Accessible *object)
41
AccessibleStateSet *state;
43
state = Accessible_getStateSet (object);
46
Check, if check box state is already checked
48
if (AccessibleStateSet_contains (state, SPI_STATE_CHECKED))
49
return TRUE; // Checked state
51
return FALSE; // Unchecked state
55
is_check_box_enabled (Accessible *object)
57
AccessibleStateSet *state;
61
if (wait_till_object_state_contains (object, CHECK_BOX, NULL) == -1) {
63
error = LDTP_ERROR_INVALID_OBJECT_STATE;
64
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), NULL);
67
state = Accessible_getStateSet (object);
69
/* Verifies it is enabled or not */
70
if (AccessibleStateSet_contains (state, SPI_STATE_ENABLED) == TRUE)
77
check_check_box (Accessible *object, FILE *log_fp)
80
AccessibleAction *action;
82
if (wait_till_object_state_contains (object, CHECK_BOX, log_fp) != 0) {
83
error = LDTP_ERROR_INVALID_OBJECT_STATE;
88
If state already selected then unselect ?
90
if (get_check_box_state (object) == FALSE) {
92
action = Accessible_getAction (object);
93
flag = AccessibleAction_doAction (action, 0);
94
Accessible_unref (action);
96
return LDTP_ERROR_SUCCESS;
98
error = LDTP_ERROR_CHECK_ACTION_FAILED;
103
log_msg (LDTP_LOG_WARNING, "Check box is already checked", log_fp);
104
return LDTP_ERROR_SUCCESS;
106
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
111
uncheck_check_box (Accessible *object, FILE *log_fp)
114
AccessibleAction *action;
116
if (wait_till_object_state_contains (object, CHECK_BOX, log_fp) != 0) {
117
error = LDTP_ERROR_INVALID_OBJECT_STATE;
122
If state is checked then only uncheck it
124
if (get_check_box_state (object) == TRUE) {
126
action = Accessible_getAction (object);
127
flag = AccessibleAction_doAction (action, 0);
128
Accessible_unref (action);
130
return LDTP_ERROR_SUCCESS;
132
error = LDTP_ERROR_UNCHECK_ACTION_FAILED;
137
log_msg (LDTP_LOG_WARNING, "Check box state already unchecked", log_fp);
138
return LDTP_ERROR_SUCCESS;
140
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
145
click (Accessible *object, FILE *log_fp)
148
SPIBoolean flag = FALSE;
149
AccessibleAction *action;
151
if (wait_till_object_state_contains (object, CHECK_BOX, log_fp) != 0) {
152
error = LDTP_ERROR_INVALID_OBJECT_STATE;
153
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
157
action = Accessible_getAction (object);
158
flag = AccessibleAction_doAction (action, 0);
159
Accessible_unref (action);
162
return LDTP_ERROR_SUCCESS;
164
return LDTP_ERROR_CLICK_FAILED;
168
verify_check_check_box (Accessible *object, FILE *log_fp)
171
if (wait_till_object_state_contains (object, CHECK_BOX, log_fp) != 0) {
172
error = LDTP_ERROR_INVALID_OBJECT_STATE;
173
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
176
if (get_check_box_state (object) == FALSE)
177
return LDTP_ERROR_STATE_UNCHECKED;
179
return LDTP_ERROR_SUCCESS;
183
verify_uncheck_check_box (Accessible *object, FILE *log_fp)
186
if (wait_till_object_state_contains (object, CHECK_BOX, log_fp) != 0) {
187
error = LDTP_ERROR_INVALID_OBJECT_STATE;
188
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
191
if (get_check_box_state (object) == TRUE)
192
return LDTP_ERROR_STATE_CHECKED;
194
return LDTP_ERROR_SUCCESS;
198
check_box_main (LDTPClientContext* cctxt, int command)
203
error = check_check_box (cctxt->gui_handle->handle, cctxt->log_fp);
205
case LDTP_CMD_UNCHECK:
206
error = uncheck_check_box (cctxt->gui_handle->handle, cctxt->log_fp);
208
case LDTP_CMD_GRABFOCUS:
209
error = grab_focus (cctxt->gui_handle->handle, cctxt->log_fp);
211
case LDTP_CMD_STATEENABLED:
212
if (is_check_box_enabled (cctxt->gui_handle->handle))
213
error = LDTP_ERROR_SUCCESS;
215
error = LDTP_ERROR_CHECK_BOX_STATE_NOT_ENABLED;
218
error = click (cctxt->gui_handle->handle, cctxt->log_fp);
220
case LDTP_CMD_VERIFYCHECK:
221
error = verify_check_check_box (cctxt->gui_handle->handle, cctxt->log_fp);
223
case LDTP_CMD_VERIFYUNCHECK:
224
error = verify_uncheck_check_box (cctxt->gui_handle->handle, cctxt->log_fp);
226
case LDTP_CMD_GETOBJECTSIZE:
227
cctxt->resp->data_len = 0;
228
cctxt->resp->data = get_size (cctxt->gui_handle->handle, &error);
229
if (cctxt->resp->data) {
230
cctxt->resp->data_len = g_utf8_strlen (cctxt->resp->data, -1);
234
error = LDTP_ERROR_COMMAND_NOT_IMPLEMENTED;