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
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Linux Desktop Testing Project http://ldtp.freedesktop.org
*
* Author:
* Nagappan Alagappan <nagappan@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-logger.h"
#include "ldtp-command.h"
#include "ldtp-gui-comp.h"
static LDTPErrorCode
toggle (Accessible *object, FILE *log_fp)
{
SPIBoolean flag = FALSE;
AccessibleAction *action;
action = Accessible_getAction (object);
flag = AccessibleAction_doAction (action, 0);
Accessible_unref (action);
if (flag == TRUE)
return LDTP_ERROR_SUCCESS;
else {
LDTPErrorCode error;
error = LDTP_ERROR_TOGGLE_ACTION_FAILED;
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
return error;
}
}
static LDTPErrorCode
invoke_menu (Accessible *object, FILE *log_fp)
{
SPIBoolean flag = FALSE;
AccessibleAction *action;
action = Accessible_getAction (object);
flag = AccessibleAction_doAction (action, 1);
Accessible_unref (action);
if (flag == TRUE)
return LDTP_ERROR_SUCCESS;
else {
LDTPErrorCode error;
error = LDTP_ERROR_TOGGLE_ACTION_FAILED;
log_msg (LDTP_LOG_CAUSE, ldtp_error_get_message (error), log_fp);
return error;
}
}
LDTPErrorCode
embedded_component_main (LDTPClientContext* cctxt, int command)
{
LDTPErrorCode error;
switch (command) {
case LDTP_CMD_CLICK:
error = toggle (cctxt->gui_handle->handle, cctxt->log_fp);
break;
case LDTP_CMD_INVOKEMENU:
case LDTP_CMD_RIGHTCLICK:
error = invoke_menu (cctxt->gui_handle->handle, cctxt->log_fp);
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;
}
|