def __init__(self, addr=DEFAULT_ADDR, unity_editor=False): if not unity_editor: # init airtest env try: # new version from airtest.core.api import connect_device, device as current_device if not current_device(): connect_device("Android:///") except ImportError: # old version from airtest.cli.runner import device as current_device from airtest.core.main import set_serialno if not current_device(): set_serialno() # unity games poco sdk listens on Android localhost:5001 current_device().adb.forward("tcp:%s" % addr[1], "tcp:5001", False) self.conn = TcpClient(addr) self.c = RpcClient(self.conn) self.c.DEBUG = False self.c.run(backend=True) self.c.wait_connected() hierarchy = FreezedUIHierarchy(Dumper(self.c), UnityAttributor(self.c)) if unity_editor: screen = UnityScreen(self.c) else: screen = AirtestScreen() input = AirtestInput() super(UnityPocoAgent, self).__init__(hierarchy, input, screen, None)
def __init__(self, addr=DEFAULT_ADDR): self.conn = TcpClient(addr) self.c = RpcClient(self.conn) self.c.connect() hierarchy = FrozenUIHierarchy(StdDumper(self.c), StdAttributor(self.c)) screen = StdScreen(self.c) inputs = AirtestInput() super(StdPocoAgent, self).__init__(hierarchy, inputs, screen, None)
def __init__(self, addr=("localhost", 5001)): conn = TcpClient(addr) self.c = RpcClient(conn) self.c.DEBUG = False self.c.run(backend=True) hierarchy = MhHierarchy(self.c) screen = MhScreen(self.c) input = MhInput(self.c) super(MhPocoAgent, self).__init__(hierarchy, input, screen, None)
def __init__(self, addr=DEFAULT_ADDR): # init airtest env self.conn = TcpClient(addr) self.c = RpcClient(self.conn) self.c.DEBUG = False self.c.wait_connected() hierarchy = FrozenUIHierarchy(Dumper(self.c), StdAttributor(self.c)) screen = StdScreen(self.c) input = AirtestInput() super(StdPocoAgent, self).__init__(hierarchy, input, screen, None)
def __init__(self, addr=DEFAULT_ADDR, use_airtest_input=True): self.conn = TcpClient(addr) self.c = RpcClient(self.conn) self.c.DEBUG = False self.c.connect() hierarchy = FrozenUIHierarchy(StdDumper(self.c), StdAttributor(self.c)) screen = StdScreen(self.c) if use_airtest_input: inputs = AirtestInput() else: inputs = StdInput(self.c) super(StdPocoAgent, self).__init__(hierarchy, inputs, screen, None)
def __init__(self, addr=DEFAULT_ADDR, unity_editor=False, connect_default_device=True): # init airtest env try: # new version from airtest.core.api import connect_device, device as current_device from airtest.core.helper import device_platform if unity_editor and not current_device(): connect_device( "Windows:///?class_name=UnityWndClass&title_re=Unity.*") game_window = current_device().app.top_window().child_window( title="UnityEditor.GameView") current_device()._top_window = game_window.wrapper_object() current_device().focus_rect = (0, 40, 0, 0) if connect_default_device and not current_device(): # currently only connect to Android as default # can apply auto detection in the future connect_device("Android:///") if device_platform() == "Android": # always forward port for Android # unity games poco sdk listens on Android localhost:5001 current_device().adb.forward("tcp:%s" % addr[1], "tcp:5001", False) except ImportError: # old version, 逐渐废弃 from airtest.cli.runner import device as current_device from airtest.core.main import set_serialno if not current_device(): set_serialno() # unity games poco sdk listens on Android localhost:5001 current_device().adb.forward("tcp:%s" % addr[1], "tcp:5001", False) self.conn = TcpClient(addr) self.c = RpcClient(self.conn) self.c.DEBUG = False self.c.wait_connected() hierarchy = FrozenUIHierarchy(Dumper(self.c), UnityAttributor(self.c)) screen = UnityScreen(self.c) input = AirtestInput() super(UnityPocoAgent, self).__init__(hierarchy, input, screen, None)