예제 #1
0
 def isListView(self, node):
     element_parser = ParseElement(node.mElement)
     element_parser.parseElmentData()
     if "list:mItemCount" in element_parser.properties_dict.keys():
         return True
     else:
         return False
예제 #2
0
    def loadProperties(self):
        # has no child
        if None==self.node.mChildNodes or 0==len(self.node.mChildNodes):
#            self.text_list.append(self.node.mText)
#            self.click_location_list.append(self.node.mLocation)

            if self.node.mVisible:         
                self.properties_dict["mText"] = [self.node.mText]
            if self.node.mClickable:
                self.properties_dict["mLocation"] = [self.node.mLocation]
                                    
            element_parser = ParseElement(self.node.mElement)
            element_parser.parseElmentData() 
            res = element_parser.getBoolean("isChecked()", False)
            self.properties_dict["isChecked"] = res
            return True
        
        # has child
        self.getChildProperties(self.node, self.properties_dict)
        
        # check again if the onClickListener event register to the list view node, also mean its parent's node
        if 0 == len(self.properties_dict["mLocation"]):
            if self.node.mParentNode.mClickable:
                self.properties_dict["mLocation"] = [self.node.mLocation]
        
        return True
예제 #3
0
 def typeTextByIndex(self, text, index):
     
     self.focusViewByIndex(index)
     
     view_text_length = len(self.focusable_view_list[index].mText)
     if view_text_length>0:
         element_parser = ParseElement(self.focusable_view_list[index].mElement)
         element_parser.parseElmentData()
         if "text:getSelectionEnd()" in element_parser.properties_dict.keys(): # or "text:getSelectionStart()"
             cursor_location = element_parser.getInt("text:getSelectionEnd()", 0)
             if view_text_length == cursor_location:
                 self.event_controller.type(text)
             elif cursor_location<view_text_length:
                 delta = view_text_length - cursor_location
                 while delta>0:
                     self.event_controller.press("dpad_right")
                     delta -= 1
                 while view_text_length>0:
                     self.event_controller.press("del")
                     view_text_length -= 1
                 self.event_controller.type(text)
                 return True
     else:
         self.event_controller.type(text)
         return True
     
     return False
예제 #4
0
 def loadProperties(self):
     index = 0
     for node in self.tree_nodes_list:
         if node.mVisible:
             if self.isListView(node):
                 for child in node.mChildNodes:
                     self.focusable_view_list.append(child)
             else:
                 element_parser = ParseElement(node.mElement)
                 element_parser.parseElmentData()
                 if "focus:isFocusable()" in element_parser.properties_dict.keys():
                     if element_parser.getBoolean("focus:isFocusable()", False):
                         self.focusable_view_list.append(node)
                         if element_parser.getBoolean("focus:isFocused()", False):  # or ["focus:hasFocus()"]
                             self.currentFocusIndex = index
                         index += 1
                             
     total = len(self.focusable_view_list)
     for i in range(total):
         if i == total-1:
             self.next_direction_list.append(None)
         else:                    
             if self.focusable_view_list[i].mLocation.y == self.focusable_view_list[i+1].mLocation.y:
                 self.next_direction_list.append("dpad_right")
             else:
                 self.next_direction_list.append("dpad_down")
                 
     for i in range(total):
         if 0 == i:
             self.pre_direction_list.append(None)
         else:
             if self.focusable_view_list[i].mLocation.y == self.focusable_view_list[i-1].mLocation.y:
                 self.pre_direction_list.append("dpad_left")
             else:
                 self.pre_direction_list.append("dpad_up")
예제 #5
0
    def typeTextByIndex(self, text, index):

        self.focusViewByIndex(index)

        view_text_length = len(self.focusable_view_list[index].mText)
        if view_text_length > 0:
            element_parser = ParseElement(
                self.focusable_view_list[index].mElement)
            element_parser.parseElmentData()
            if "text:getSelectionEnd()" in element_parser.properties_dict.keys(
            ):  # or "text:getSelectionStart()"
                cursor_location = element_parser.getInt(
                    "text:getSelectionEnd()", 0)
                if view_text_length == cursor_location:
                    self.event_controller.type(text)
                elif cursor_location < view_text_length:
                    delta = view_text_length - cursor_location
                    while delta > 0:
                        self.event_controller.press("dpad_right")
                        delta -= 1
                    while view_text_length > 0:
                        self.event_controller.press("del")
                        view_text_length -= 1
                    self.event_controller.type(text)
                    return True
        else:
            self.event_controller.type(text)
            return True

        return False
예제 #6
0
 def isListView(self, node):
     element_parser = ParseElement(node.mElement)
     element_parser.parseElmentData()
     if "list:mItemCount" in element_parser.properties_dict.keys():
         return True
     else:
         return False
예제 #7
0
    def loadProperties(self):
        # has no child
        if None==self.node.mChildNodes or 0==len(self.node.mChildNodes):
#            self.text_list.append(self.node.mText)
#            self.click_location_list.append(self.node.mLocation)

            if self.node.mVisible:         
                self.properties_dict["mText"] = [self.node.mText]
            if self.node.mClickable:
                self.properties_dict["mLocation"] = [self.node.mLocation]
                                    
            element_parser = ParseElement(self.node.mElement)
            element_parser.parseElmentData() 
            res = element_parser.getBoolean("isChecked()", False)
            self.properties_dict["isChecked"] = res
            return True
        
        # has child
        self.getChildProperties(self.node, self.properties_dict)
        
        # check again if the onClickListener event register to the list view node, also mean its parent's node
        if 0 == len(self.properties_dict["mLocation"]):
            if self.node.mParentNode.mClickable:
                self.properties_dict["mLocation"] = [self.node.mLocation]
        
        return True
예제 #8
0
 def getChildProperties(self, node, properties_dict):
     if None==node:
         return properties_dict
     
     if None==node.mChildNodes or 0==len(node.mChildNodes):
         return properties_dict
     
     for child in node.mChildNodes:
         if self.isLeafNode(child):
             if child.mVisible:
                 properties_dict["mText"].append(child.mText)
             if child.mClickable:                    
                 properties_dict["mLocation"].append(child.mLocation) # this might be TBD
                 
             element_parser = ParseElement(child.mElement)
             element_parser.parseElmentData() 
             res = None
             if "isChecked()" in element_parser.properties_dict.keys():
                 res = element_parser.getBoolean("isChecked()", False)
                 properties_dict["isChecked"] = (res or properties_dict["isChecked"])
             
         else:
             self.getChildProperties(child, properties_dict)
예제 #9
0
 def getChildProperties(self, node, properties_dict):
     if None==node:
         return properties_dict
     
     if None==node.mChildNodes or 0==len(node.mChildNodes):
         return properties_dict
     
     for child in node.mChildNodes:
         if self.isLeafNode(child):
             if child.mVisible:
                 properties_dict["mText"].append(child.mText)
             if child.mClickable:                    
                 properties_dict["mLocation"].append(child.mLocation) # this might be TBD
                 
             element_parser = ParseElement(child.mElement)
             element_parser.parseElmentData() 
             res = None
             if "isChecked()" in element_parser.properties_dict.keys():
                 res = element_parser.getBoolean("isChecked()", False)
                 properties_dict["isChecked"] = (res or properties_dict["isChecked"])
             
         else:
             self.getChildProperties(child, properties_dict)
예제 #10
0
    def loadProperties(self):
        index = 0
        for node in self.tree_nodes_list:
            if node.mVisible:
                if self.isListView(node):
                    for child in node.mChildNodes:
                        self.focusable_view_list.append(child)
                else:
                    element_parser = ParseElement(node.mElement)
                    element_parser.parseElmentData()
                    if "focus:isFocusable()" in element_parser.properties_dict.keys(
                    ):
                        if element_parser.getBoolean("focus:isFocusable()",
                                                     False):
                            self.focusable_view_list.append(node)
                            if element_parser.getBoolean(
                                    "focus:isFocused()",
                                    False):  # or ["focus:hasFocus()"]
                                self.currentFocusIndex = index
                            index += 1

        total = len(self.focusable_view_list)
        for i in range(total):
            if i == total - 1:
                self.next_direction_list.append(None)
            else:
                if self.focusable_view_list[
                        i].mLocation.y == self.focusable_view_list[
                            i + 1].mLocation.y:
                    self.next_direction_list.append("dpad_right")
                else:
                    self.next_direction_list.append("dpad_down")

        for i in range(total):
            if 0 == i:
                self.pre_direction_list.append(None)
            else:
                if self.focusable_view_list[
                        i].mLocation.y == self.focusable_view_list[
                            i - 1].mLocation.y:
                    self.pre_direction_list.append("dpad_left")
                else:
                    self.pre_direction_list.append("dpad_up")