zoukankan      html  css  js  c++  java
  • android Instrumentoation 问答

    android Instrumentoation 问答

     

    1、instrumentation是执行application instrumentation代码的基类。当应用程序运行的时候instrumentation处于开启,instrumentation将在任何应用程序运行前初始化,可以通过它监测系统与应用程序的交互。

    2、instrumentation implementation通过AndroidManifest.xml中的<instrumentation>标签进行描述
    3、instrumentation有些类似windows中的hook函数,在系统与应用程序之间安装了个qieting器。
     
    如何实现一个button的点击?
    测试类继承InstrumentationTestCase 该类在android.test包内
    重写setUp函数
    @Override
    protected void setup() throws Exception{
    super.setUp();
    Intent intent=new Intent();
    intent.setClassName("被测app包名","被测app主Activity类名")
    getInstrumentation().startActivitySync(Intent intent)//得到被测app的mainActivity
     
    getInstrumentation方法得到一个instrumentation实例,该类是android.app包里面的一个类,在被测app启动时该类已经被初始化了,直接用getInstrumentation方法得到该实例,无需再去new一个。
     
    //Execute a call on the application's main thread, blocking until it is complete.
    getInstrumentation().runOnMainSync(Runnable runner)
    注:runner里封装一个view,run方法调用该view自己的click事件
    view.PerformClick(); //调用view的click事件
  • 相关阅读:
    Kail命令
    [UIScreen mainScreen].applicationFrame与[UIScreen mainScreen].bounds区别
    Excel使用技巧
    vs2012配置OpenGL
    IP首部校验和的计算
    链接保存
    Android精讲--界面编程1(界面编程与视图的组件)
    Intent对象详解
    安卓四大组件之--Service
    android的事件处理机制
  • 原文地址:https://www.cnblogs.com/poptest/p/5124666.html
Copyright © 2011-2022 走看看