Example #1
0
class UnityPocoAgent(PocoAgent):
    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)

    @sync_wrapper
    def get_debug_profiling_data(self):
        return self.c.call("GetDebugProfilingData")
Example #2
0
class CocosJsPocoAgent(PocoAgent):
    def __init__(self, addr=DEFAULT_ADDR):
        # 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()
        # cocos games poco sdk listens on Android localhost:5003
        localport = addr.split(":")[-1]
        current_device().adb.forward("tcp:%s" % localport, "tcp:5003", False)

        self.conn = WebSocketClient(addr)
        self.c = RpcClient(self.conn)
        self.c.DEBUG = False
        self.c.run(backend=True)
        self.c.wait_connected()

        hierarchy = FreezedUIHierarchy(Dumper(self.c))
        screen = AirtestScreen()
        input = AirtestInput()
        super(CocosJsPocoAgent, self).__init__(hierarchy, input, screen, None)
Example #3
0
class MhPocoAgent(PocoAgent):
    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)
Example #4
0
def dump():
    conn = TcpClient(DEFAULT_ADDR)
    c = RpcClient(conn)
    c.DEBUG = False
    c.run(backend=True)
    time.sleep(2)
    t0 = time.time()
    d = Dumper(c)
    h = d.dumpHierarchy()
    t1 = time.time()
    print(t1 - t0)
    return h