Пример #1
0
def testMenu():
    m_logger = Logger.InitLog("testMenu.log", logging.getLogger("testMenu.thread"))
    
    # init device
    device = Device(m_logger)
    device.open()
    data = device.getDumpData()
    
    # build View Tree
    vt = ViewTree(m_logger)
    tree_nodes_list = vt.build(data)
    
    # if current view is a system component
    menu = Menu(tree_nodes_list)
    elements_list = menu.getElementList()
    
    # if current view is not a system component, use "tree_nodes_list" directly: node.mElement
    #for node in tree_nodes_list:
    #    view_element = ViewElement(node.mElement)
    #    ......
    #    ......
    
    # View Element
    for element in elements_list:
        print "begin deal with [%s]" %element.mText
        view_element = ViewElement(element)
Пример #2
0
def testMenu():
    m_logger = Logger.InitLog("testMenu.log",
                              logging.getLogger("testMenu.thread"))

    # init device
    device = Device(m_logger)
    device.open()
    data = device.getDumpData()

    # build View Tree
    vt = ViewTree(m_logger)
    tree_nodes_list = vt.build(data)

    # if current view is a system component
    menu = Menu(tree_nodes_list)
    elements_list = menu.getElementList()

    # if current view is not a system component, use "tree_nodes_list" directly: node.mElement
    #for node in tree_nodes_list:
    #    view_element = ViewElement(node.mElement)
    #    ......
    #    ......

    # View Element
    for element in elements_list:
        print "begin deal with [%s]" % element.mText
        view_element = ViewElement(element)
Пример #3
0
class SoloInterface():
    '''
    Solo Interface for Automated Testing
    '''
        
    Android_Class_Name_Dict = { "Button":  "android.widget.Button",
                                "CheckBox": "android.widget.CheckBox",
                                "EditText" : "android.widget.EditText",
                                "ImageButton": "android.widget.ImageButton",
                                "ImageVIew": "android.widget.ImageView",
                                "RadioButton": "android.widget.RadioButton",
                                "TextView": "android.widget.TextView",
                                "View": "android.view.View",
                                "ProgressBar": "android.widget.ProgressBar",
                                "ScrollView": "android.widget.ScrollView"}
          
    def __init__(self, device_name="emulator-5554", device_port=5554, device_address="127.0.0.1", view_server_port=4939, monkey_server_port=12345):
        '''
        Constructor
        '''
        self.class_name = "SoloInterface"
        self.m_logger = Logger.InitLog("solo-interface.log", logging.getLogger("solo-interface.thread"))
        
        self.device_name = device_name
        self.device_port = device_port
        self.device_address = device_address
        
        self.view_server_port = view_server_port
        self.monkey_server_port = monkey_server_port
        
        # object of Device
        self.device = Device(self.m_logger, self.device_name, self.device_port, self.device_address, self.view_server_port, self.monkey_server_port)        
        # init device
        self.device.open()
        
        # build View Tree
        self.vt = ViewTree(self.m_logger)
        
        self.tree_nodes_list = None
        
        # object of View Controller 
        self.event_controller = EventController(self.m_logger, self.device_name, self.device_port, self.device_address, self.monkey_server_port)
        # init event controller
        self.event_controller.open()
        
        try:
            self.device_display_width = int(self.event_controller.getDisplayWidth())
            self.device_display_height = int(self.event_controller.getDisplayHeight())
        except Exception, e:
            print e
        # to 480*800 display
        # Notification (y: 0-37  / x: 8-471 )
        self.notification_height = 37
class SoloInterface():
    '''
    Solo Interface for Automated Testing
    '''

    Android_Class_Name_Dict = {
        "Button": "android.widget.Button",
        "CheckBox": "android.widget.CheckBox",
        "EditText": "android.widget.EditText",
        "ImageButton": "android.widget.ImageButton",
        "ImageVIew": "android.widget.ImageView",
        "RadioButton": "android.widget.RadioButton",
        "TextView": "android.widget.TextView",
        "View": "android.view.View",
        "ProgressBar": "android.widget.ProgressBar",
        "ScrollView": "android.widget.ScrollView"
    }

    def __init__(self,
                 device_name="emulator-5554",
                 device_port=5554,
                 device_address="127.0.0.1",
                 view_server_port=4939,
                 monkey_server_port=12345):
        '''
        Constructor
        '''
        self.class_name = "SoloInterface"
        self.m_logger = Logger.InitLog(
            "solo-interface.log", logging.getLogger("solo-interface.thread"))

        self.device_name = device_name
        self.device_port = device_port
        self.device_address = device_address

        self.view_server_port = view_server_port
        self.monkey_server_port = monkey_server_port

        # object of Device
        self.device = Device(self.m_logger, self.device_name, self.device_port,
                             self.device_address, self.view_server_port,
                             self.monkey_server_port)
        # init device
        self.device.open()

        # build View Tree
        self.vt = ViewTree(self.m_logger)

        self.tree_nodes_list = None

        # object of View Controller
        self.event_controller = EventController(self.m_logger,
                                                self.device_name,
                                                self.device_port,
                                                self.device_address,
                                                self.monkey_server_port)
        # init event controller
        self.event_controller.open()

        try:
            self.device_display_width = int(
                self.event_controller.getDisplayWidth())
            self.device_display_height = int(
                self.event_controller.getDisplayHeight())

#            LCD density is in the build.prop:
#            adb shell getprop ro.sf.lcd_density
#            And the resolution is availble in the dumpsys of the input activity:
#            # windows
#            adb shell dumpsys window | find "DisplayWidth"
#            # linux
#            adb shell dumpsys window | grep DisplayWidth
        except Exception, e:
            print "Failed to get device display width and height: [%s]" % str(
                e)
        # to 480*800 display
        # Notification (y: 0-37  / x: 8-471 )
        self.notification_height = 37

        self.abs_action_bar_bottom = None
Пример #5
0
class SoloInterface:
    """
    Solo Interface for Automated Testing
    """

    Android_Class_Name_Dict = {
        "Button": "android.widget.Button",
        "CheckBox": "android.widget.CheckBox",
        "EditText": "android.widget.EditText",
        "ImageButton": "android.widget.ImageButton",
        "ImageVIew": "android.widget.ImageView",
        "RadioButton": "android.widget.RadioButton",
        "TextView": "android.widget.TextView",
        "View": "android.view.View",
        "ProgressBar": "android.widget.ProgressBar",
        "ScrollView": "android.widget.ScrollView",
    }

    def __init__(
        self,
        device_name="emulator-5554",
        device_port=5554,
        device_address="127.0.0.1",
        view_server_port=4939,
        monkey_server_port=12345,
    ):
        """
        Constructor
        """
        self.class_name = "SoloInterface"
        self.m_logger = Logger.InitLog("solo-interface.log", logging.getLogger("solo-interface.thread"))

        self.device_name = device_name
        self.device_port = device_port
        self.device_address = device_address

        self.view_server_port = view_server_port
        self.monkey_server_port = monkey_server_port

        # object of Device
        self.device = Device(
            self.m_logger,
            self.device_name,
            self.device_port,
            self.device_address,
            self.view_server_port,
            self.monkey_server_port,
        )
        # init device
        self.device.open()

        # build View Tree
        self.vt = ViewTree(self.m_logger)

        self.tree_nodes_list = None

        # object of View Controller
        self.event_controller = EventController(
            self.m_logger, self.device_name, self.device_port, self.device_address, self.monkey_server_port
        )
        # init event controller
        self.event_controller.open()

        try:
            self.device_display_width = int(self.event_controller.getDisplayWidth())
            self.device_display_height = int(self.event_controller.getDisplayHeight())

        #            LCD density is in the build.prop:
        #            adb shell getprop ro.sf.lcd_density
        #            And the resolution is availble in the dumpsys of the input activity:
        #            # windows
        #            adb shell dumpsys window | find "DisplayWidth"
        #            # linux
        #            adb shell dumpsys window | grep DisplayWidth
        except Exception, e:
            print "Failed to get device display width and height: [%s]" % str(e)
        # to 480*800 display
        # Notification (y: 0-37  / x: 8-471 )
        self.notification_height = 37

        self.abs_action_bar_bottom = None