[LDTP-Dev] added api for gettextstate()

Prashanth Mohan prashmohan at gmail.com
Tue Dec 13 06:07:20 PST 2005


i have added an API for getting the state of a textbox (editable/uneditable)

the patch is attached

Index: ldtp.c
===================================================================
RCS file: /cvs/pyldtp.old/ldtp.c,v
retrieving revision 1.149
retrieving revision 1.151
diff -u -p -r1.149 -r1.151
--- ldtp.c      5 Dec 2005 10:19:14 -0000       1.149
+++ ldtp.c      13 Dec 2005 05:45:51 -0000      1.151
@@ -659,7 +659,7 @@ static PyObject *ldtp_main (int command)
       command == VERIFYSELECT || command == COMPARETEXTPROPERTY ||
       command == CONTAINSTEXTPROPERTY || command == VERIFYCHECKROW ||
       command == DOESROWEXIST || command == GETSTATUSBARTEXT ||
-      command == VERIFYUNCHECKROW || command == GETSLIDERVALUE)
+      command == VERIFYUNCHECKROW || command == GETSLIDERVALUE ||
command == GETTEXTENABLE)
     {
       Accessible_unref (accessible);
       return Py_BuildValue ("i", status);
@@ -963,7 +963,7 @@ static PyObject *insert_text (PyObject *

   if (!PyArg_ParseTuple (args, "ssis", &window_name, &component_name,
&pos, text))
     return PyErr_Format (ldtp_error, "%s %s %d", "Argument missing /
invalid", __FILE__, __LINE__);
-
+
   params = malloc (sizeof (char ) * 2);
   params[0] = g_strdup_printf ("%s", text);
   params[1] = g_strdup_printf ("%d", pos);
@@ -1018,6 +1018,18 @@ static PyObject *delete_text (PyObject *
   return status;
 }

+static PyObject *get_text_state (PyObject *self, PyObject *args)
+{
+  PyObject *status;
+
+  if (!PyArg_ParseTuple (args, "ss", &window_name, &component_name))
+    return PyErr_Format (ldtp_error, "%s %s %d", "Argument missing /
invalid", __FILE__, __LINE__);
+
+  status = ldtp_main (GETTEXTENABLE);
+
+  return status;
+}
+
 static PyObject *show_list (PyObject *self, PyObject *args)
 {
   PyObject *status;
@@ -2662,6 +2674,8 @@ static PyMethodDef ldtp_methods[] = {
    "paste text"},
   {"deletetext", (PyCFunction) delete_text, METH_VARARGS,
    "delete text"},
+  {"gettextstate", (PyCFunction) get_text_state, METH_VARARGS,
+   "Gets the present state of the textbox"},
   {"showlist", (PyCFunction) show_list, METH_VARARGS,
    "Show list"},
   {"verifydropdown", (PyCFunction) verify_drop_down, METH_VARARGS,

Index: text.c
===================================================================
RCS file: /cvs/pyldtp.old/text.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -r1.49 -r1.50
28a29,46
>
> static int get_text_state (Accessible *object)
> {
>     AccessibleStateSet *state;
>     state = Accessible_getStateSet (object);
>
>     if (AccessibleStateSet_contains (state, SPI_STATE_EDITABLE))
>       {
>         log_msg (LOG_INFO,"TEXT: TextBox is editable");
>       return 1; /*text box is editable*/
>       }
>     else
>       {
>         log_msg (LOG_INFO,"TEXT: TextBox is not editable");
>       return 0; /*text box is not editable*/
>       }
> }
>
617c635,637
<       return contains_text_property (object, params);
---
>       return contains_text_property (object, params);
>     case GETTEXTENABLE:
>       return get_text_state (object);

Index: gui.h
===================================================================
RCS file: /cvs/pyldtp.old/gui.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -r1.33 -r1.34
228a229
> #define GETTEXTENABLE 312

--
Prashanth Mohan
http://prash.be
---


More information about the LDTP-dev mailing list