from constants import *
from accessible import *
+from action import *
from application import *
from component import *
from desktop import *
folders, and others.
"""
- def doAction(self, *args, **kwargs):
+ def doAction(self, index):
"""
doAction:
@param : index
@return : a boolean indicating success or failure.
"""
func = self.get_dbus_method("doAction")
- return func(*args, **kwargs)
+ return func(index)
- def getDescription(self, *args, **kwargs):
+ def getDescription(self, index):
"""
getDescription:
@param : index
action.
"""
func = self.get_dbus_method("getDescription")
- return func(*args, **kwargs)
+ return func(index)
- def getKeyBinding(self, *args, **kwargs):
+ def getKeyBinding(self, index):
"""
getKeyBinding:
@param : index
action, or an empty string ("") if none exists.
"""
func = self.get_dbus_method("getKeyBinding")
- return func(*args, **kwargs)
+ return func(index)
- def getName(self, *args, **kwargs):
+ def getName(self, index):
"""
getName:
@param : index
@return : a string containing the name of the specified action.
"""
func = self.get_dbus_method("getName")
- return func(*args, **kwargs)
+ return func(index)
def get_nActions(self):
- self._pgetter(self._dbus_interface, "nActions")
+ return self._pgetter(self._dbus_interface, "nActions")
def set_nActions(self, value):
self._psetter(self._dbus_interface, "nActions", value)
_nActionsDoc = \
self._pgetter = self.get_dbus_method("Get", dbus_interface="org.freedesktop.DBus.Properties")
self._psetter = self.get_dbus_method("Set", dbus_interface="org.freedesktop.DBus.Properties")
- def __getattr__(*args, **kwargs):
- return object.__getattr__(*args, **kwargs)
+ def __getattr__(self, attr):
+ raise AttributeError("\'%s\' has no attribute \'%s\'" % (self.__class__.__name__, attr))
def get_dbus_method(self, *args, **kwargs):
method = Interface.get_dbus_method(self, *args, **kwargs)
check_PROGRAMS = test-application
-check_LTLIBRARIES = libnoopapp.la libaccessibleapp.la libcomponentapp.la
+check_LTLIBRARIES = libnoopapp.la \
+ libaccessibleapp.la \
+ libcomponentapp.la \
+ libactionapp.la
test_application_CFLAGS = $(DBUS_GLIB_CFLAGS) \
$(ATK_CFLAGS) \
libcomponentapp_la_LDFLAGS = $(TEST_APP_LDFLAGS)
libcomponentapp_la_LIBADD = $(TEST_APP_LIBADD)
libcomponentapp_la_SOURCES = component-app.c
+
+libactionapp_la_CFLAGS = $(TEST_APP_CFLAGS)
+libactionapp_la_LDFLAGS = $(TEST_APP_LDFLAGS)
+libactionapp_la_LIBADD = $(TEST_APP_LIBADD)
+libactionapp_la_SOURCES = action-app.c
--- /dev/null
+#include <gmodule.h>
+#include <atk/atk.h>
+#include <my-atk.h>
+
+static AtkObject *root_accessible;
+
+G_MODULE_EXPORT void
+test_init (gchar *path)
+{
+ root_accessible = g_object_new(MY_TYPE_ATK_ACTION, NULL);
+}
+
+G_MODULE_EXPORT void
+test_next (int argc, char *argv[])
+{
+ g_print("Moving to next stage\n");
+}
+
+G_MODULE_EXPORT void
+test_finished (int argc, char *argv[])
+{
+ g_print("Test has completed\n");
+}
+
+G_MODULE_EXPORT AtkObject *
+test_get_root (void)
+{
+ return root_accessible;
+}
{
self->actions[i].name = (gchar*)strdup(DEFAULT_ACTION_NAME);
self->actions[i].description = (gchar*)strdup(DEFAULT_ACTION_DESCRIPTION);
- self->actions[i].keybinding = (gchar*)strdup(DEFAULT_ACTION_KEYBINDING);
+ self->actions[i].keybinding = g_strdup_printf("%d", i);
}
self->disposed = FALSE;
self->last_performed_action = -1;
static const gchar* keybinding_note_define = "none";
-#define FIRST_ACTION_NAME "Default action"
-#define FIRST_ACTION_DESCRIPTION "This action will be perfomed by default"
-#define FIRST_ACTION_KEYBINDING "12345"
+#define FIRST_ACTION_NAME "First action"
+#define FIRST_ACTION_DESCRIPTION "First action performed"
+#define FIRST_ACTION_KEYBINDING "0"
#define DEFAULT_NUMBER_ACTIONS 10
#define DEFAULT_ACTION_NAME "Action"
--- /dev/null
+import dbus
+import gobject
+import os.path
+
+from xml.dom import minidom
+import os
+
+from pasytest import PasyTest as _PasyTest
+
+import pyatspi
+
+class ActionTest(_PasyTest):
+
+ __tests__ = ["setup",
+ "test_nActions",
+ "test_getDescription",
+ "test_getName",
+ "test_doAction",
+ "test_getKeyBinding",
+ "teardown",
+ ]
+
+ def __init__(self, bus, path):
+ _PasyTest.__init__(self, "Action", False)
+ self._bus = bus
+ self._path = path
+
+ def setup(self, test):
+ self._registry = pyatspi.registry.Registry(self._path)
+ self._desktop = self._registry.getDesktop(0)
+
+ def test_nActions(self, test):
+ root = self._desktop[0]
+ root = root.queryAction()
+ nact = root.nActions
+ test.assertEqual(nact, 10, "nActions expected %d, recieved %d" % (10, nact))
+
+ def test_getName(self, test):
+ root = self._desktop[0]
+ root = root.queryAction()
+ name = root.getName(0)
+ test.assertEqual(name, "First action", "Name expected %s, recieved %s" % ("First action", name))
+ name = root.getName(1)
+ test.assertEqual(name, "Action", "Name expected %s, recieved %s" % ("Action", name))
+
+ def test_getDescription(self, test):
+ root = self._desktop[0]
+ root = root.queryAction()
+ description = root.getDescription(0)
+ expected = "First action performed"
+ test.assertEqual(description, expected, "Description expected %s, recieved %s" % (expected, description))
+ description = root.getDescription(1)
+ expected = "Description of action"
+ test.assertEqual(description, expected, "Description expected %s, recieved %s" % (expected, description))
+
+ def test_doAction(self, test):
+ root = self._desktop[0]
+ root = root.queryAction()
+ #TODO have event emitted to check action has been performed
+ for i in range(0, root.nActions):
+ root.doAction(i)
+
+ def test_getKeyBinding(self, test):
+ root = self._desktop[0]
+ root = root.queryAction()
+ for i in range(0, root.nActions):
+ keybinding = root.getKeyBinding(i)
+ expected = "%s" % (i,)
+ test.assertEqual(keybinding, expected,
+ "Keybinding expected %s, recieved %s" % (expected, keybinding))
+
+ def teardown(self, test):
+ pass