zoukankan      html  css  js  c++  java
  • 老李推荐:第14章6节《MonkeyRunner源码剖析》 HierarchyViewer实现原理-装备ViewServer-启动ViewServer

    老李推荐:第14章6节《MonkeyRunner源码剖析》 HierarchyViewer实现原理-装备ViewServer-启动ViewServer

     

       poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标。如果对课程感兴趣,请大家咨询qq:908821478,咨询电话010-84505200。

    在获得ViewServer的运行状态后,如果ViewServer还没有启动的话,HierarchyViewer的setupViewServer的下一步就会去启动ViewServer。调用的方法是DeviceBridge.startViewServer,我们进去看看:

     

    190     public static boolean startViewServer(IDevice device) {  

    191         return startViewServer(device, DEFAULT_SERVER_PORT);  

    192     }  

    代码14-6-1 DeviceBridge-startViewServer

    传入的参数是ddmlib的Device类的一个实例,方法很简单,直接转发给startViewServer的另一个重载函数,并且增加多一个4939(DEFAULT_SERVER_PORT)的端口号作为参数:

     

    193     public static boolean startViewServer(IDevice device, int port) {  

    194         final boolean[] result = new boolean[1];  

    195         try {  

    196             if (device.isOnline()) {  

    197                 device.executeShellCommand(buildStartServerShellCommand(port),  

    198                         new BooleanResultReader(result));  

    199             }  

    200         } catch (TimeoutException e) {  

    ...  

    208         }  

    209         return result[0];  

    210     }  

    代码14-6-2 DeviceBridge-startViewServer重载

    流程跟上一小节发送”adb shell service call window 3”来查询ViewServer一样,都是先去组建命令字串,然后通过Device实例把这个命令给发出去,只是命令不一样而已。这里我们看下发送的是什么命令:

     

    229     private static String buildStartServerShellCommand(int port) {  

    230         return String.format("service call window %d i32 %d", SERVICE_CODE_START_SERVER, port); //$NON-NLS-1$  

    231     }  

    代码14-6-3 DeviceBridge - BuildStartServerShellCommand

    其中 SERVICE_CODE_START_SERVER 全局变量是定义为1,所以可以看到最终组合的命令就是”service call window 1 i32 4939”最终结合Device的executeShellCommand命令就等于是发送”adb shell service call window 1 i32 4939”命令来启动ViewServer来监听4939端口了。这个命令我们在第13章也已经见识过了。

  • 相关阅读:
    在 Windows 上测试 Redis Cluster的集群填坑笔记
    vmware安装黑苹果教程
    微信支付v3发布到iis时的证书问题
    Linux下安装SQL Server 2016(连接篇SQL Server on linux)
    Linux下安装SQL Server 2016(连接篇SQL Server on linux)
    Linux下安装SQL Server 2016(安装篇SQL Server on linux)
    Linux下安装SQL Server 2016(准备篇SQL Server on linux)
    客服端与服务端APP支付宝支付接口联调的那些坑
    ASP.NET MVC]WebAPI应用支持HTTPS的经验总结
    .net平台下C#socket通信(中)
  • 原文地址:https://www.cnblogs.com/poptest/p/5099796.html
Copyright © 2011-2022 走看看