コード例 #1
0
    def getActionBarItemsNumber(self, actionbar_id, actionbar_classname=None):
        if None == actionbar_id or 0 == len(actionbar_id):
            return None

        real_id = "id/" + actionbar_id
        for node in self.tree_nodes_list:
            if real_id == node.mId:
                element_parser = ParseElement.ParseElement(node.mElement)
                element_parser.parseElmentData()
                if None != actionbar_classname and 0 != len(
                        actionbar_classname):
                    if actionbar_classname == node.mClassName:
                        if "list:mItemCount" in element_parser.properties_dict.keys(
                        ):
                            return int(element_parser.
                                       properties_dict["list:mItemCount"])
                        else:
                            actionbar = ActionBar.ActionBar(node)
                            actionbar.loadAllItems()
                            return len(actionbar.items_list)
                else:
                    if "list:mItemCount" in element_parser.properties_dict.keys(
                    ):
                        return int(
                            element_parser.properties_dict["list:mItemCount"])
                    else:
                        actionbar = ActionBar.ActionBar(node)
                        actionbar.loadAllItems()
                        return len(actionbar.items_list)
        return None
コード例 #2
0
    def getItemsNumber(self, groupview_id, groupview_classname=None):
        if None == groupview_id or 0 == len(groupview_id):
            return None

        real_id = "id/" + groupview_id
        for node in self.tree_nodes_list:
            if real_id == node.mId:
                element_parser = ParseElement.ParseElement(node.mElement)
                element_parser.parseElmentData()
                if None != groupview_classname and 0 != len(
                        groupview_classname):
                    if groupview_classname == node.mClassName:
                        if "list:mItemCount" in element_parser.properties_dict.keys(
                        ):
                            return int(element_parser.
                                       properties_dict["list:mItemCount"])
                        else:
                            return len(node.mChildNodes)
                else:
                    if "list:mItemCount" in element_parser.properties_dict.keys(
                    ):
                        return int(
                            element_parser.properties_dict["list:mItemCount"])
                    else:
                        return len(node.mChildNodes)

        return None
コード例 #3
0
    def getProgressById(self, id):
        if 0 == len(id):
            return None

        real_id = "id/" + id
        for node in self.tree_nodes_list:
            if (node.mClassName
                    == self.ProgressBar_ClassName) and (real_id == node.mId):
                element_parser = ParseElement.ParseElement(node.mElement)
                element_parser.parseElmentData()
                if element_parser.getBoolean(
                        element_parser.
                        properties_dict["progress:isIndeterminate()"], True):
                    continue
                max_value = element_parser.getInt(
                    element_parser.properties_dict["progress:getMax()"], 100)
                current_value = element_parser.getInt(
                    element_parser.properties_dict["progress:getProgress()"],
                    0)
                second_value = element_parser.getInt(
                    element_parser.
                    properties_dict["progress:getSecondaryProgress()"], 0)

                percent = float(current_value) / float(max_value) * 100
                if percent > 0 and percent <= 100:
                    return percent

                percent = float(second_value) / float(max_value) * 100
                if percent > 0 and percent <= 100:
                    return percent

        return None
コード例 #4
0
    def isCheckedById(self, id):
        view_name_list = [
            "android.widget.RadioButton", "android.widget.CheckBox"
        ]
        if 0 == len(id):
            return False

        real_id = "id/" + id
        for node in self.tree_nodes_list:
            if self.isViewType(node.mClassName,
                               view_name_list) and (real_id == node.mId):
                element_parser = ParseElement.ParseElement(node.mElement)
                element_parser.parseElmentData()
                return element_parser.getBoolean("isChecked()", False)

        return False
コード例 #5
0
    def isCheckedByText(self, text, partial_matching=True):
        view_name_list = [
            "android.widget.RadioButton", "android.widget.CheckBox"
        ]
        if 0 == len(text):
            return False

        if partial_matching:
            for node in self.tree_nodes_list:
                try:
                    if node.mVisible and self.isViewType(
                            node.mClassName,
                            view_name_list) and (node.mText != None) and (
                                node.mText.find(text) >= 0):
                        element_parser = ParseElement.ParseElement(
                            node.mElement)
                        element_parser.parseElmentData()
                        return element_parser.getBoolean("isChecked()", False)
                except Exception, e:
                    self.m_logger.error(
                        "Current text fail to find sub string: [%s] " % e)
                    continue
コード例 #6
0
    def getProgressByKeyWord(self, key_word):
        if 0 == len(key_word):
            return None

        for node in self.tree_nodes_list:
            try:
                if node.mVisible and (node.mClassName
                                      == self.ProgressBar_ClassName) and (
                                          node.mText != None) and (
                                              node.mText.find(key_word) >= 0):
                    element_parser = ParseElement.ParseElement(node.mElement)
                    element_parser.parseElmentData()
                    if element_parser.getBoolean(
                            element_parser.
                            properties_dict["progress:isIndeterminate()"],
                            True):
                        continue
                    max_value = element_parser.getInt(
                        element_parser.properties_dict["progress:getMax()"],
                        100)
                    current_value = element_parser.getInt(
                        element_parser.
                        properties_dict["progress:getProgress()"], 0)
                    second_value = element_parser.getInt(
                        element_parser.
                        properties_dict["progress:getSecondaryProgress()"], 0)

                    percent = float(current_value) / float(max_value) * 100
                    if percent > 0 and percent <= 100:
                        return percent

                    percent = float(second_value) / float(max_value) * 100
                    if percent > 0 and percent <= 100:
                        return percent
            except Exception, e:
                self.m_logger.error(
                    "Current text fail to find sub string: [%s] " % e)
                continue
コード例 #7
0
                                node.mText.find(text) >= 0):
                        element_parser = ParseElement.ParseElement(
                            node.mElement)
                        element_parser.parseElmentData()
                        return element_parser.getBoolean("isChecked()", False)
                except Exception, e:
                    self.m_logger.error(
                        "Current text fail to find sub string: [%s] " % e)
                    continue
        else:
            for node in self.tree_nodes_list:
                try:
                    if node.mVisible and self.isViewType(
                            node.mClassName, view_name_list) and (
                                node.mText != None) and (text == node.mText):
                        element_parser = ParseElement.ParseElement(
                            node.mElement)
                        element_parser.parseElmentData()
                        return element_parser.getBoolean("isChecked()", False)
                except Exception, e:
                    self.m_logger.error(
                        "Current text fail to match string: [%s] " % e)
                    continue
        return False

#internal interface------------------------------------------------------------------------------

    '''
    judge whether class name belongs to view_name_list
    @param param: node.mClassName
                 list of views name
    @return: True or False