Example #1
0
    def getobjectproperty(self, window_name, object_name, prop):
        """
        Get object property value.
        
        @param window_name: Window name to look for, either full name,
        LDTP's name convention, or a Unix glob.
        @type window_name: string
        @param object_name: Object name to look for, either full name,
        LDTP's name convention, or a Unix glob. 
        @type object_name: string
        @param prop: property name.
        @type prop: string

        @return: property
        @rtype: string
        """
        obj_info=self._get_object_map(window_name, object_name,
                                      wait_for_object=False)
        if obj_info and prop != "obj" and prop in obj_info:
            if prop == "class":
                # ldtp_class_type are compatible with Linux and Windows class name
                # If defined class name exist return that,
                # else return as it is
                return ldtp_class_type.get(obj_info[prop], obj_info[prop])
            else:
                return obj_info[prop]
        raise LdtpServerException('Unknown property "%s" in %s' % \
                                      (prop, object_name))
Example #2
0
 def _insert_obj(self, obj_dict, obj, parent, child_index):
     ldtpized_name = self._ldtpize_accessible(obj)
     if ldtpized_name[0] in self._ldtpized_obj_index:
         self._ldtpized_obj_index[ldtpized_name[0]] += 1
     else:
         self._ldtpized_obj_index[ldtpized_name[0]] = 0
     try:
         key = "%s%s" % (ldtpized_name[0], ldtpized_name[1])
     except UnicodeEncodeError:
         key = "%s%s" % (ldtpized_name[0], ldtpized_name[1].decode("utf-8"))
     if not ldtpized_name[1]:
         index = 0
         # Object doesn't have any associated label
         key = "%s%d" % (ldtpized_name[0], index)
     else:
         index = 1
     while obj_dict.has_key(key):
         # If the same object type with matching label exist
         # add index to it
         try:
             key = "%s%s%d" % (ldtpized_name[0], ldtpized_name[1], index)
         except UnicodeEncodeError:
             key = "%s%s%d" % (ldtpized_name[0],
                               ldtpized_name[1].decode("utf-8"), index)
         index += 1
     if ldtpized_name[0] == "frm":
         # Window
         # FIXME: As in Linux (app#index, rather than window#index)
         obj_index = "%s#%d" % (ldtpized_name[0],
                                self._ldtpized_obj_index[ldtpized_name[0]])
     else:
         # Object inside the window
         obj_index = "%s#%d" % (ldtpized_name[0],
                                self._ldtpized_obj_index[ldtpized_name[0]])
     if parent in obj_dict:
         _current_children = obj_dict[parent]["children"]
         if _current_children:
             _current_children = "%s %s" % (_current_children, key)
         else:
             _current_children = key
         obj_dict[parent]["children"] = _current_children
     actual_role = self._get_role(obj)
     obj_dict[key] = {
         "obj": obj,
         # Use Linux based class type for compatibility
         # If class type doesn't exist in list, use actual type
         "class": ldtp_class_type.get(actual_role, actual_role),
         "label": ldtpized_name[1],
         "parent": parent,
         "children": "",
         "child_index": child_index,
         "obj_index": obj_index
     }
     return key
Example #3
0
 def _insert_obj(self, obj_dict, obj, parent, child_index):
     ldtpized_name=self._ldtpize_accessible(obj)
     if ldtpized_name[0] in self._ldtpized_obj_index:
         self._ldtpized_obj_index[ldtpized_name[0]] += 1
     else:
         self._ldtpized_obj_index[ldtpized_name[0]]=0
     try:
         key="%s%s" % (ldtpized_name[0], ldtpized_name[1])
     except UnicodeEncodeError:
         key="%s%s" % (ldtpized_name[0],
                       ldtpized_name[1].decode("utf-8"))
     if not ldtpized_name[1]:
         index=0
         # Object doesn't have any associated label
         key="%s%d" % (ldtpized_name[0], index)
     else:
         index=1
     while obj_dict.has_key(key):
         # If the same object type with matching label exist
         # add index to it
         try:
             key="%s%s%d" % (ldtpized_name[0],
                             ldtpized_name[1], index)
         except UnicodeEncodeError:
             key="%s%s%d" % (ldtpized_name[0],
                             ldtpized_name[1].decode("utf-8"), index)
         index += 1
     if ldtpized_name[0] == "frm":
         # Window
         # FIXME: As in Linux (app#index, rather than window#index)
         obj_index="%s#%d" % (ldtpized_name[0],
                              self._ldtpized_obj_index[ldtpized_name[0]])
     else:
         # Object inside the window
         obj_index="%s#%d" % (ldtpized_name[0],
                              self._ldtpized_obj_index[ldtpized_name[0]])
     if parent in obj_dict:
         _current_children=obj_dict[parent]["children"]
         if _current_children:
             _current_children="%s %s" % (_current_children, key)
         else:
             _current_children=key
         obj_dict[parent]["children"]=_current_children
     actual_role=self._get_role(obj)
     obj_dict[key]={"obj" : obj,
                    # Use Linux based class type for compatibility
                    # If class type doesn't exist in list, use actual type
                    "class" : ldtp_class_type.get(actual_role, actual_role),
                    "label" : ldtpized_name[1],
                    "parent" : parent,
                    "children" : "",
                    "child_index" : child_index,
                    "obj_index" : obj_index}
     return key
Example #4
0
    def getobjectproperty(self, window_name, object_name, prop):
        """
        Get object property value.

        @param window_name: Window name to look for, either full name,
        LDTP's name convention, or a Unix glob.
        @type window_name: string
        @param object_name: Object name to look for, either full name,
        LDTP's name convention, or a Unix glob.
        @type object_name: string
        @param prop: property name.
        @type prop: string

        @return: property
        @rtype: string
        """
        try:
            obj_info = self._get_object_map(window_name,
                                            object_name,
                                            wait_for_object=False)
        except atomac._a11y.ErrorInvalidUIElement:
            # During the test, when the window closed and reopened
            # ErrorInvalidUIElement exception will be thrown
            self._windows = {}
            # Call the method again, after updating apps
            obj_info = self._get_object_map(window_name,
                                            object_name,
                                            wait_for_object=False)
        if obj_info and prop != "obj" and prop in obj_info:
            if prop == "class":
                # ldtp_class_type are compatible with Linux and Windows class name
                # If defined class name exist return that,
                # else return as it is
                return ldtp_class_type.get(obj_info[prop], obj_info[prop])
            else:
                return obj_info[prop]
        raise LdtpServerException('Unknown property "%s" in %s' % \
                                      (prop, object_name))
Example #5
0
    def getobjectproperty(self, window_name, object_name, prop):
        """
        Get object property value.

        @param window_name: Window name to look for, either full name,
        LDTP's name convention, or a Unix glob.
        @type window_name: string
        @param object_name: Object name to look for, either full name,
        LDTP's name convention, or a Unix glob.
        @type object_name: string
        @param prop: property name.
        @type prop: string

        @return: property
        @rtype: string
        """
        try:
            obj_info=self._get_object_map(window_name, object_name,
                                          wait_for_object=False)
        except atomac._a11y.ErrorInvalidUIElement:
            # During the test, when the window closed and reopened
            # ErrorInvalidUIElement exception will be thrown
            self._windows={}
            # Call the method again, after updating apps
            obj_info=self._get_object_map(window_name, object_name,
                                          wait_for_object=False)
        if obj_info and prop != "obj" and prop in obj_info:
            if prop == "class":
                # ldtp_class_type are compatible with Linux and Windows class name
                # If defined class name exist return that,
                # else return as it is
                return ldtp_class_type.get(obj_info[prop], obj_info[prop])
            else:
                return obj_info[prop]
        raise LdtpServerException('Unknown property "%s" in %s' % \
                                      (prop, object_name))