[pyatspi2/gi] Various fixes; unit tests now pass



commit 13c22290cd8fb82936594328a290cda108ff828c
Author: Mike Gorse <mgorse novell com>
Date:   Sun Nov 28 10:07:15 2010 -0500

    Various fixes; unit tests now pass

 pyatspi/Accessibility.py           |  113 ++++++++++++++++++++++++++++--
 pyatspi/__init__.py                |    9 ++-
 pyatspi/state.py                   |    1 +
 tests/apps/atk-object-xml-loader.c |    9 ++-
 tests/apps/component-app.c         |    2 +-
 tests/data/accessible-test.xml     |    2 +-
 tests/dummyatk/Makefile.am         |    2 +
 tests/dummyatk/my-atk-document.c   |  137 ++++++++++++++++++++++++++++++++++++
 tests/dummyatk/my-atk-document.h   |   40 +++++++++++
 tests/dummyatk/my-atk-text.c       |    2 +-
 tests/dummyatk/my-atk.h            |    1 +
 tests/pyatspi/accessibletest.py    |    7 +--
 tests/pyatspi/collectiontest.py    |    1 +
 tests/pyatspi/relationtest.py      |    2 +-
 14 files changed, 309 insertions(+), 19 deletions(-)
---
diff --git a/pyatspi/Accessibility.py b/pyatspi/Accessibility.py
index 343cf86..71bbd5c 100644
--- a/pyatspi/Accessibility.py
+++ b/pyatspi/Accessibility.py
@@ -42,38 +42,108 @@ def rangeToList(r):
 def textRangeToList(r):
 	return (r.start_offset, r.end_offset, r.text)
 
+# TODO: Figure out how to override Atspi.Rect constructor and remove this class
+class BoundingBox(list):
+        def __new__(cls, x, y, width, height):
+                return list.__new__(cls, (x, y, width, height))
+        def __init__(self, x, y, width, height):
+                list.__init__(self, (x, y, width, height))
+
+        def __str__(self):
+                return ("(%d, %d, %d, %d)" % (self.x, self.y, self.width, self.height))
+
+        def _get_x(self):
+                return self[0]
+        def _set_x(self, val):
+                self[0] = val
+        x = property(fget=_get_x, fset=_set_x)
+        def _get_y(self):
+                return self[1]
+        def _set_y(self, val):
+                self[1] = val
+        y = property(fget=_get_y, fset=_set_y)
+        def _get_width(self):
+                return self[2]
+        def _set_width(self, val):
+                self[2] = val
+        width = property(fget=_get_width, fset=_set_width)
+        def _get_height(self):
+                return self[3]
+        def _set_height(self, val):
+                self[3] = val
+        height = property(fget=_get_height, fset=_set_height)
+
+def getBoundingBox(rect):
+	return BoundingBox (rect.x, rect.y, rect.width, rect.height)
+
+def attributeListToHash(list):
+	ret = dict()
+	for key, val in list:
+		ret[key] = val
+	return ret
+
 ### Accessible ###
+Accessible = Atspi.Accessible
 Atspi.Accessible.getChildAtIndex = Atspi.Accessible.get_child_at_index
 Atspi.Accessible.getAttributes = Atspi.Accessible.get_attributes_as_array
 Atspi.Accessible.getApplication = Atspi.Accessible.get_host_application
 Atspi.Accessible.__getitem__ = Accessible_getitem
 Atspi.Accessible.__len__ = Atspi.Accessible.get_child_count
 Atspi.Accessible.__nonzero__ = lambda x: True
-Atspi.Accessible.name = property(fget=Atspi.Accessible.get_name)
+Atspi.Accessible.childCount = property(fget=Atspi.Accessible.get_child_count)
+Atspi.Accessible.getIndexInParent = Atspi.Accessible.get_index_in_parent
+Atspi.Accessible.getLocalizedRoleName = Atspi.Accessible.get_localized_role_name
+Atspi.Accessible.getRelationSet = Atspi.Accessible.get_relation_set
 Atspi.Accessible.getRole = Atspi.Accessible.get_role
+Atspi.Accessible.getRoleName = Atspi.Accessible.get_role_name
+Atspi.Accessible.getState = Atspi.Accessible.get_state_set
+Atspi.Accessible.name = property(fget=Atspi.Accessible.get_name)
+Atspi.Accessible.isEqual = lambda a,b: a == b
+Atspi.Accessible.parent = property(fget=Atspi.Accessible.get_parent)
 
 ### action ###
+Action = Atspi.Action
 Atspi.Accessible.queryAction = Atspi.Accessible.get_action
 Atspi.Action.doAction = Atspi.Action.do_action
 Atspi.Action.getDescription = Atspi.Action.get_description
 Atspi.Action.getKeyBinding = Atspi.Action.get_key_binding
 Atspi.Action.getName = Atspi.Action.get_name
-Atspi.Action.get_nActions = Atspi.Action.get_n_actions
+Atspi.Action.nActions = property(fget=Atspi.Action.get_n_actions)
 
 ### collection ###
+Collection = Atspi.Collection
 Atspi.Accessible.queryCollection = Atspi.Accessible.get_collection
 Atspi.Collection.isAncesterOf = Atspi.Collection.is_ancestor_of
-Atspi.Collection.createMatchRule = lambda x, s, smt, a, amt, r, rmt, inv: Atspi.MatchRule.new (s, smt, a, amt, i, imt, r, rmt, inv)
+Atspi.Collection.createMatchRule = lambda x, s, smt, a, amt, r, rmt, i, imt, inv: Atspi.MatchRule.new (s, smt, attributeListToHash(a), amt, r, rmt, i, imt, inv)
 Atspi.Collection.getMatches = Atspi.Collection.get_matches
 Atspi.Collection.getMatchesFrom = Atspi.Collection.get_matches_from
 Atspi.Collection.getMatchesTo = Atspi.Collection.get_matches_to
 Atspi.Collection.getActiveDescendant = Atspi.Collection.get_active_descendant
 
+Atspi.Collection.MATCH_INVALID = Atspi.CollectionMatchType.INVALID
+Atspi.Collection.MATCH_ALL = Atspi.CollectionMatchType.ALL
+Atspi.Collection.MATCH_ANY = Atspi.CollectionMatchType.ANY
+Atspi.Collection.MATCH_NONE = Atspi.CollectionMatchType.NONE
+Atspi.Collection.MATCH_EMPTY = Atspi.CollectionMatchType.EMPTY
+
+Atspi.Collection.SORT_ORDER_INVALID = Atspi.CollectionSortOrder.INVALID
+Atspi.Collection.SORT_ORDER_CANONICAL = Atspi.CollectionSortOrder.CANONICAL
+Atspi.Collection.SORT_ORDER_FLOWAL = Atspi.CollectionSortOrder.FLOW
+Atspi.Collection.SORT_ORDER_TAB = Atspi.CollectionSortOrder.TAB
+Atspi.Collection.SORT_ORDER_REVERSE_CANONICAL = Atspi.CollectionSortOrder.REVERSE_CANONICAL
+Atspi.Collection.SORT_ORDER_REVERSE_FLOW = Atspi.CollectionSortOrder.REVERSE_FLOW
+Atspi.Collection.SORT_ORDER_REVERSE_TAB = Atspi.CollectionSortOrder.REVERSE_TAB
+
+Atspi.Collection.TREE_RESTRICT_CHILDREN = Atspi.CollectionTreeTraversalType.RESTRICT_CHILDREN
+Atspi.Collection.TREE_RESTRICT_SIBLING = Atspi.CollectionTreeTraversalType.RESTRICT_SIBLING
+Atspi.Collection.TREE_INORDER = Atspi.CollectionTreeTraversalType.INORDER
+
 ### component ###
+Component = Atspi.Component
 Atspi.Accessible.queryComponent = Atspi.Accessible.get_component
 Atspi.Component.getAccessibleAtPoint = Atspi.Component.get_accessible_at_point
 Atspi.Component.getAlpha = Atspi.Component.get_alpha
-Atspi.Component.getExtents = lambda x,c: rectToList(Atspi.Component.get_extents(x,c))
+Atspi.Component.getExtents = lambda x,c: getBoundingBox(Atspi.Component.get_extents(x,c))
 Atspi.Component.getLayer = Atspi.Component.get_layer
 Atspi.Component.getMDIZOrder = Atspi.Component.get_mdi_z_order
 Atspi.Component.getPosition = lambda x,p: pointToList(Atspi.Component.get_position(x,p))
@@ -81,12 +151,14 @@ Atspi.Component.getSize = lambda x: pointToList(Atspi.Component.get_size(x))
 Atspi.Component.grabFocus = Atspi.Component.grab_focus
 
 ### document ###
+Document = Atspi.Document
 Atspi.Accessible.queryDocument = Atspi.Accessible.get_document
 Atspi.Document.getAttributevalue = Atspi.Document.get_attribute_value
 Atspi.Document.getAttributes = lambda x: [key + ":" + value for key, value in Atspi.Document.get_attributes (x)]
 Atspi.Document.getLocale = Atspi.Document.get_locale
 
 ### editable text ###
+EditableText = Atspi.EditableText
 Atspi.Accessible.queryEditableText = Atspi.Accessible.get_editable_text
 Atspi.EditableText.copyText = Atspi.EditableText.copy_text
 Atspi.EditableText.cutText = Atspi.EditableText.cut_text
@@ -96,6 +168,7 @@ Atspi.EditableText.pasteText = Atspi.EditableText.paste_text
 Atspi.EditableText.setTextContents = Atspi.EditableText.set_text_contents
 
 ### hyperlink ###
+Hyperlink = Atspi.Hyperlink
 Atspi.Hyperlink.getObject = Atspi.Hyperlink.get_object
 Atspi.Hyperlink.getURI = Atspi.Hyperlink.get_uri
 Atspi.Hyperlink.isValid = Atspi.Hyperlink.is_valid
@@ -104,20 +177,23 @@ Atspi.Hyperlink.get_nAnchors = Atspi.Hyperlink.get_n_anchors
 Atspi.Hyperlink.get_startIndex = Atspi.Hyperlink.get_start_index
 
 ### hypertext ###
+Hypertext = Atspi.Hypertext
 Atspi.Accessible.queryHypertet = Atspi.Accessible.get_hypertext
 Atspi.Hypertext.getLink = Atspi.Hypertext.get_link
 Atspi.Hypertext.getLinkIndex = Atspi.Hypertext.get_link_index
 Atspi.Hypertext.getNLinks = Atspi.Hypertext.get_n_links
 
 ### image ###
+Image = Atspi.Image
 Atspi.Accessible.queryImage = Atspi.Accessible.get_image
-Atspi.Image.getImageExtents = lambda x,c: rectToList(Atspi.Image.get_image_extents(x,c))
+Atspi.Image.getImageExtents = lambda x,c: getBoundingBox(Atspi.Image.get_image_extents(x,c))
 Atspi.Image.getImagePosition = lambda x,p: pointToList(Atspi.Image.get_image_position(x,p))
 Atspi.Image.getImageSize = lambda x: pointToList(Atspi.Image.get_image_size(x))
 Atspi.Image.get_imageDescription = Atspi.Image.get_image_description
 Atspi.Image.get_imageLocale = Atspi.Image.get_image_locale
 
 ### selection ###
+Selection = Atspi.Selection
 Atspi.Accessible.querySelection = Atspi.Accessible.get_selection
 Atspi.Selection.clearSelectio = Atspi.Selection.clear_selection
 Atspi.Selection.deselectChild = Atspi.Selection.deselect_child
@@ -129,6 +205,7 @@ Atspi.Selection.selectChild = Atspi.Selection.select_child
 Atspi.Selection.get_nSelectedChildren = Atspi.Selection.get_n_selected_children
 
 ### table ###
+Table = Atspi.Table
 Atspi.Accessible.queryTable = Atspi.Accessible.get_table
 Atspi.Table.addColumnSelection = Atspi.Table.add_column_selection
 Atspi.Table.addRowSelection = Atspi.Table.add_row_selection
@@ -156,6 +233,7 @@ Atspi.Table.get_nSelectedColumns = Atspi.Table.get_n_selected_columns
 Atspi.Table.get_nSelectedRows = Atspi.Table.get_n_selected_rows
 
 ### text ###
+Text = Atspi.Text
 Atspi.Accessible.queryText = Atspi.Accessible.get_text
 Atspi.Text.addSelection = Atspi.Text.add_selection
 Atspi.Text.getAttributeRun = lambda x,o,i: textAttrToList (Atspi.Text.get_attribute_run (x,o,i))
@@ -181,6 +259,7 @@ Atspi.Text.get_caretOffset = Atspi.Text.get_caret_offset
 Atspi.Text.get_characterCount = Atspi.Text.get_character_count
 
 ### value ###
+Value = Atspi.Value
 Atspi.Accessible.queryValue = Atspi.Accessible.get_value
 Atspi.Value.get_currentValue = Atspi.Value.get_current_value
 Atspi.Value.set_currentValue = Atspi.Value.set_current_value
@@ -190,3 +269,27 @@ Atspi.Value.get_minimumValue = Atspi.Value.get_minimum_value
 
 ### event ###
 Atspi.Event.host_application = lambda x: x.source.host_application
+
+### RelationSet ###
+Atspi.Relation.getRelationType = Atspi.Relation.get_relation_type
+Atspi.Relation.getNTargets = Atspi.Relation.get_n_targets
+Atspi.Relation.getTarget = Atspi.Relation.get_target
+RELATION_NULL = Atspi.RelationType.NULL
+RELATION_LABEL_FOR = Atspi.RelationType.LABEL_FOR
+RELATION_LABELLED_BY = Atspi.RelationType.LABELLED_BY
+RELATION_CONTROLLER_FOR = Atspi.RelationType.CONTROLLER_FOR
+RELATION_CONTROLLED_BY = Atspi.RelationType.CONTROLLED_BY
+RELATION_MEMBER_OF = Atspi.RelationType.MEMBER_OF
+RELATION_TOOLTIP_FOR = Atspi.RelationType.TOOLTIP_FOR
+RELATION_NODE_CHILD_OF = Atspi.RelationType.NODE_CHILD_OF
+RELATION_NODE_PARENT_OF = Atspi.RelationType.NODE_PARENT_OF
+RELATION_EXTENDED = Atspi.RelationType.EXTENDED
+RELATION_FLOWS_TO = Atspi.RelationType.FLOWS_TO
+RELATION_FLOWS_FROM = Atspi.RelationType.FLOWS_FROM
+RELATION_SUBWINDOW_OF = Atspi.RelationType.SUBWINDOW_OF
+RELATION_EMBEDS = Atspi.RelationType.EMBEDS
+RELATION_POPUP_FOR = Atspi.RelationType.POPUP_FOR
+RELATION_PARENT_WINDOW_OF = Atspi.RelationType.PARENT_WINDOW_OF
+RELATION_DESCRIPTION_FOR = Atspi.RelationType.DESCRIPTION_FOR
+RELATION_DESCRIBED_BY = Atspi.RelationType.DESCRIBED_BY
+
diff --git a/pyatspi/__init__.py b/pyatspi/__init__.py
index cad1bb1..fadee13 100644
--- a/pyatspi/__init__.py
+++ b/pyatspi/__init__.py
@@ -38,8 +38,11 @@ if useCorba:
 else:
     __version__ = (1, 9, 0)
 
-# TODO: Look at pyatspi2 __init__.py; recreate namespace pollution, etc.
+    from gi.repository import Atspi
 
-from gi.repository import Atspi
+    from Accessibility import *
 
-from Accessibility import *
+    #This is a re-creation of the namespace pollution implemented
+    #by PyORBit.
+    import Accessibility
+    sys.modules['Accessibility'] = Accessibility
diff --git a/pyatspi/state.py b/pyatspi/state.py
index f5800f0..75e2bcd 100644
--- a/pyatspi/state.py
+++ b/pyatspi/state.py
@@ -165,4 +165,5 @@ def stateset_init(self, *states):
 StateSet = Atspi.StateSet
 StateSet.getStates = StateSet.get_states
 StateSet.isEmpty = StateSet.is_empty
+StateSet.raw = lambda x: x
 StateSet.__init__ = stateset_init
diff --git a/tests/apps/atk-object-xml-loader.c b/tests/apps/atk-object-xml-loader.c
index 5fa2354..0b05326 100644
--- a/tests/apps/atk-object-xml-loader.c
+++ b/tests/apps/atk-object-xml-loader.c
@@ -31,6 +31,7 @@
 #define NAME_ATTR ((const xmlChar *) "name")
 #define DESC_ATTR ((const xmlChar *) "description")
 #define ROLE_ATTR ((const xmlChar *) "role")
+#define TYPE_ATTR ((const xmlChar *) "type")
 
 static MyAtkObject *
 create_atk_object_from_element(xmlNode *element)
@@ -43,14 +44,20 @@ create_atk_object_from_element(xmlNode *element)
   xmlChar *name;
   xmlChar *description;
   xmlChar *role_text; 
+  xmlChar *type_text;
   gint role;
+  GType type = MY_TYPE_ATK_OBJECT;
 
   name = xmlGetProp(element, NAME_ATTR);
   description = xmlGetProp(element, DESC_ATTR);
   role_text = xmlGetProp(element, ROLE_ATTR);
   role = atoi(role_text);
+  type_text = xmlGetProp(element, TYPE_ATTR);
 
-  obj = MY_ATK_OBJECT(g_object_new(MY_TYPE_ATK_OBJECT,
+  if (type_text && !strcmp (type_text, "document"))
+    type = MY_TYPE_ATK_DOCUMENT;
+
+  obj = MY_ATK_OBJECT(g_object_new(type,
 				   "accessible-name", name,
 				   "accessible-description", description,
 				   "accessible-role", role,
diff --git a/tests/apps/component-app.c b/tests/apps/component-app.c
index 3c96228..c926513 100644
--- a/tests/apps/component-app.c
+++ b/tests/apps/component-app.c
@@ -56,5 +56,5 @@ test_finished (int argc, char *argv[])
 G_MODULE_EXPORT AtkObject *
 test_get_root (void)
 {
-  return ATK_COMPONENT(comps[2]);
+  return ATK_OBJECT(comps[2]);
 }
diff --git a/tests/data/accessible-test.xml b/tests/data/accessible-test.xml
index abab68c..000a10b 100644
--- a/tests/data/accessible-test.xml
+++ b/tests/data/accessible-test.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" ?>
-<accessible description="The main accessible object, root of the accessible tree" name="atspi-test-main" role="68">
+<accessible description="The main accessible object, root of the accessible tree" name="atspi-test-main" role="68" type="document">
 	<accessible description="" name="gnome-settings-daemon" role="77"/>
 	<accessible description="" name="gnome-panel" role="77">
 		<accessible description="" name="Bottom Expanded Edge Panel" role="24"/>
diff --git a/tests/dummyatk/Makefile.am b/tests/dummyatk/Makefile.am
index 2e93052..786d1c8 100644
--- a/tests/dummyatk/Makefile.am
+++ b/tests/dummyatk/Makefile.am
@@ -13,6 +13,8 @@ libdummyatk_la_SOURCES = my-atk-action.c		\
 			 my-atk-action.h		\
 			 my-atk-component.c		\
 			 my-atk-component.h		\
+	my-atk-document.c \
+	my-atk-document.h \
 			 my-atk-hyperlink.c		\
 			 my-atk-hyperlink.h		\
 			 my-atk-hypertext.c		\
diff --git a/tests/dummyatk/my-atk-document.c b/tests/dummyatk/my-atk-document.c
new file mode 100644
index 0000000..eab6aba
--- /dev/null
+++ b/tests/dummyatk/my-atk-document.c
@@ -0,0 +1,137 @@
+/* This file contains both declaration and definition of the MyAtkDocument,
+ * a GObject that pretends to implement the AtkDocumentIface interface (it 
+ * registers appropriate interface), but provides no implementation for any of the
+ * methods of this interface (NULL-filled vftbl).
+ */
+
+#include <glib-object.h>
+#include <atk/atk.h> 
+
+#include "my-atk-object.h"
+#include "my-atk-document.h"
+    
+///////////////////////////////////////////////////////////////////////////
+// Helper functions and data
+///////////////////////////////////////////////////////////////////////////
+const gchar *
+my_atk_document_get_document_locale (AtkDocument *document)
+{
+  return DEF_LOCALE_TEXT;
+}
+
+const gchar *
+my_atk_document_get_document_type (AtkDocument *document)
+{
+  return DEF_TYPE_TEXT;
+}
+
+AtkAttributeSet *
+my_atk_document_get_document_attributes (AtkDocument *document)
+{
+  /* TODO: Implement */
+  return NULL;
+}
+
+const gchar *
+my_atk_document_get_document_attribute_value (AtkDocument *document, const gchar *value)
+{
+  /*( TODO: Implement */
+  return NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Implementation
+///////////////////////////////////////////////////////////////////////////
+static GObjectClass *parent_class_document = NULL;
+
+/******************************************************************/
+static void
+document_interface_init (gpointer g_iface, gpointer iface_data)
+{
+    AtkDocumentIface *klass = (AtkDocumentIface *)g_iface;
+    
+    /* set up overrides here */
+    klass-> get_document_type = my_atk_document_get_document_type;
+    klass-> get_document_locale = my_atk_document_get_document_locale;
+    klass-> get_document_attributes = my_atk_document_get_document_attributes;
+    klass-> get_document_attribute_value = my_atk_document_get_document_attribute_value;
+}
+
+static void
+document_instance_init (GTypeInstance *instance, gpointer g_class)
+{
+    MyAtkDocument *self = (MyAtkDocument *)instance;
+    
+    self->disposed = FALSE;
+}
+
+static void
+my_atk_document_dispose (GObject *obj)
+{
+    MyAtkDocument *self = (MyAtkDocument *)obj;
+
+    if (self->disposed) 
+    {
+        return;
+    }
+    
+    /* Make sure dispose does not run twice. */
+    self->disposed = TRUE;
+
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS (parent_class_document)->dispose (obj);
+}
+
+static void
+my_atk_document_finalize (GObject *obj)
+{
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS (parent_class_document)->finalize (obj);
+}
+
+static void
+my_atk_document_class_init (gpointer g_class, gpointer g_class_data)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
+    MyAtkDocumentClass *klass = MY_ATK_DOCUMENT_CLASS (g_class);
+
+    gobject_class->dispose = my_atk_document_dispose;
+    gobject_class->finalize = my_atk_document_finalize;
+
+    parent_class_document = g_type_class_peek_parent (klass);
+}
+
+GType 
+my_atk_document_get_type (void)
+{
+    static GType type = 0;
+    if (type == 0) 
+    {
+        static const GTypeInfo info = 
+        {
+            sizeof (MyAtkDocumentClass),
+            NULL,   /* base_init */
+            NULL,   /* base_finalize */
+            my_atk_document_class_init, /* class_init */
+            NULL,   /* class_finalize */
+            NULL,   /* class_data */
+            sizeof (MyAtkDocument),
+            0,      /* n_preallocs */
+            document_instance_init    /* instance_init */
+        };
+                
+        static const GInterfaceInfo iface_info = 
+        {
+            (GInterfaceInitFunc) document_interface_init,    /* interface_init */
+            NULL,                                       /* interface_finalize */
+            NULL                                        /* interface_data */
+        };
+        type = g_type_register_static (MY_TYPE_ATK_OBJECT,
+                                       "MyAtkDocumentType",
+                                       &info, 0);
+        g_type_add_interface_static (type,
+                                     ATK_TYPE_DOCUMENT,
+                                     &iface_info);
+    }
+    return type;
+}
diff --git a/tests/dummyatk/my-atk-document.h b/tests/dummyatk/my-atk-document.h
new file mode 100644
index 0000000..c4b2478
--- /dev/null
+++ b/tests/dummyatk/my-atk-document.h
@@ -0,0 +1,40 @@
+#ifndef MY_ATK_DOCUMENT_H
+#define MY_ATK_DOCUMENT_H
+
+#include <glib-object.h>
+#include <atk/atk.h> 
+#include <my-atk-object.h>
+    
+#define MY_TYPE_ATK_DOCUMENT             (my_atk_document_get_type ())
+#define MY_ATK_DOCUMENT(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), MY_TYPE_ATK_DOCUMENT, MyAtkDocument))
+#define MY_ATK_DOCUMENT_CLASS(vdocument)    (G_TYPE_CHECK_CLASS_CAST ((vdocument), MY_TYPE_ATK_DOCUMENT, MyAtkDocumentClass))
+#define MY_IS_ATK_DOCUMENT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MY_TYPE_ATK_DOCUMENT))
+#define MY_IS_ATK_DOCUMENT_CLASS(vdocument) (G_TYPE_CHECK_CLASS_TYPE ((vdocument), MY_TYPE_ATK_DOCUMENT))
+#define MY_ATK_DOCUMENT_GET_CLASS(inst)  (G_TYPE_INSTANCE_GET_CLASS ((inst), MY_TYPE_ATK_DOCUMENT, MyAtkDocumentClass))
+
+// default string values
+#define DEF_LOCALE_TEXT  "en-US"
+#define DEF_TYPE_TEXT    "default type"
+
+typedef struct _MyAtkDocument MyAtkDocument;
+typedef struct _MyAtkDocumentClass MyAtkDocumentClass;
+
+struct _MyAtkDocument 
+{
+    MyAtkObject parent;
+        
+    gboolean disposed;
+    
+  gchar *locale;
+  gchar *document_type;
+};
+
+struct _MyAtkDocumentClass 
+{
+    MyAtkObjectClass parent;
+};
+
+GType 
+my_atk_document_get_type (void);
+
+#endif /*MY_ATK_DOCUMENT_H*/
diff --git a/tests/dummyatk/my-atk-text.c b/tests/dummyatk/my-atk-text.c
index 6729c4b..dcca0ab 100644
--- a/tests/dummyatk/my-atk-text.c
+++ b/tests/dummyatk/my-atk-text.c
@@ -934,7 +934,7 @@ gboolean my_atk_text_set_selection(AtkText *text,
 {
     MyAtkText *self = (MyAtkText*)text;
     GArray *selections = self->selections;
-    if(selection_num < 0 || selection_num >= selections->len) return NULL;
+    if(selection_num < 0 || selection_num >= selections->len) return FALSE;
     
     if((selection_num == 0 
         || g_array_index(selections, TextSelection, selection_num - 1).end_offset <= start_offset)
diff --git a/tests/dummyatk/my-atk.h b/tests/dummyatk/my-atk.h
index 935d3d8..0ab937d 100644
--- a/tests/dummyatk/my-atk.h
+++ b/tests/dummyatk/my-atk.h
@@ -4,6 +4,7 @@
 #include <my-atk-action.h>
 #include <my-atk-component.h>
 #include <my-atk.h>
+#include <my-atk-document.h>
 #include <my-atk-hyperlink.h>
 #include <my-atk-hypertext.h>
 #include <my-atk-object.h>
diff --git a/tests/pyatspi/accessibletest.py b/tests/pyatspi/accessibletest.py
index 3b5efd1..dfbcf9e 100644
--- a/tests/pyatspi/accessibletest.py
+++ b/tests/pyatspi/accessibletest.py
@@ -96,12 +96,7 @@ class AccessibleTest(_PasyTest):
 
 	def test_getApplication(self, test):
 		root = self._root
-		print root._app_name
-		print root._acc_path
 		application = root.getApplication()
-		print application._app_name
-		print application._acc_path
-		print application
 		if not root.isEqual(application):
 			test.fail("Root accessible does not provide itself as its Application")
 
@@ -117,7 +112,7 @@ class AccessibleTest(_PasyTest):
 		res = ["foo:bar", "baz:qux", "quux:corge"]
                 attr.sort()
                 res.sort()
-		test.assertEqual(attr, res, "Attributes expected %s, recieved %s" % (attr, res))
+		test.assertEqual(attr, res, "Attributes expected %s, recieved %s" % (res, attr))
 
 	def test_parent(self, test):
 		root = self._root
diff --git a/tests/pyatspi/collectiontest.py b/tests/pyatspi/collectiontest.py
index abb6254..b15404f 100644
--- a/tests/pyatspi/collectiontest.py
+++ b/tests/pyatspi/collectiontest.py
@@ -95,6 +95,7 @@ class AccessibleTest(_PasyTest):
 
                 obj=ret[2]
                 ret = collection.getMatchesTo (obj, rule, collection.SORT_ORDER_REVERSE_CANONICAL, collection.TREE_INORDER, True, 5, True)
+		print "--ret:", len(ret)
                 self.assertObjects(test,ret,(
                         "gnome-settings-daemon", 79,
                         "gnome-panel", 79,
diff --git a/tests/pyatspi/relationtest.py b/tests/pyatspi/relationtest.py
index b39ae1c..47fb814 100644
--- a/tests/pyatspi/relationtest.py
+++ b/tests/pyatspi/relationtest.py
@@ -29,7 +29,7 @@ class RelationTest(_PasyTest):
 		self._desktop = self._registry.getDesktop(0)
                 self._root = pyatspi.findDescendant (self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole() == pyatspi.ROLE_APPLICATION)
 		self._rset = self._root.getRelationSet()
-		test.assertEqual(len(self._rset), 4, "Num relations expected %d, recieved %d" % (6, len(self._rset)))
+		test.assertEqual(len(self._rset), 4, "Num relations expected %d, recieved %d" % (4, len(self._rset)))
 
 	def test_getRelationType(self, test):
 		expected = [pyatspi.RELATION_EMBEDS,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]