class StdPocoAgent(PocoAgent): 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) @property def rpc(self): return self.c @sync_wrapper def get_debug_profiling_data(self): return self.c.call("GetDebugProfilingData") @sync_wrapper def get_sdk_version(self): return self.c.call('GetSDKVersion') def on_bind_driver(self, driver): super(StdPocoAgent, self).on_bind_driver(driver) if isinstance(self.input, AirtestInput): self.input.add_preaction_cb(driver)
class StdPocoAgent(PocoAgent): 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) @property def rpc(self): return self.c @sync_wrapper def get_debug_profiling_data(self): return self.c.call("GetDebugProfilingData") @sync_wrapper def get_sdk_version(self): return self.c.call('GetSDKVersion')
class CocosJsPocoAgent(PocoAgent): def __init__(self, port, device=None): self.device = device or current_device() if not self.device: self.device = connect_device("Android:///") platform_name = device_platform(self.device) if platform_name == 'Android': local_port, _ = self.device.adb.setup_forward( 'tcp:{}'.format(port)) ip = self.device.adb.host or 'localhost' port = local_port elif platform_name == 'IOS': # Note: ios is now support for now. # ip = device.get_ip_address() # use iproxy first ip = 'localhost' local_port, _ = self.device.instruct_helper.setup_proxy(port) port = local_port else: ip = self.device.get_ip_address() # transport self.conn = WebSocketClient('ws://{}:{}'.format(ip, port)) self.c = RpcClient(self.conn) self.c.connect() hierarchy = FrozenUIHierarchy(Dumper(self.c)) screen = AirtestScreen() inputs = AirtestInput() super(CocosJsPocoAgent, self).__init__(hierarchy, inputs, screen, None) @property def rpc(self): return self.c
class CocosJsPocoAgent(PocoAgent): def __init__(self, addr=DEFAULT_ADDR): try: port = int(addr.rsplit(":", 1)[-1]) except ValueError: raise ValueError( 'Argument `addr` should be a string-like format. e.g. "ws://192.168.1.2:5003". Got {}' .format(repr(addr))) if not current_device(): connect_device("Android:///") if device_platform() == 'Android': local_port, _ = current_device().adb.setup_forward( 'tcp:{}'.format(port)) ip = 'localhost' port = local_port elif device_platform() == 'IOS': # Note: ios is now support for now. # ip = device.get_ip_address() # use iproxy first ip = 'localhost' local_port, _ = current_device().instruct_helper.setup_proxy(port) port = local_port else: import socket ip = socket.gethostbyname(socket.gethostname()) self.conn = WebSocketClient('ws://{}:{}'.format(ip, port)) self.c = RpcClient(self.conn) self.c.connect() hierarchy = FrozenUIHierarchy(Dumper(self.c)) screen = AirtestScreen() inputs = AirtestInput() super(CocosJsPocoAgent, self).__init__(hierarchy, inputs, screen, None) @property def rpc(self): return self.c