Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何制作能够启动我的机器人测试的APK?_Android_Testing_Robotium - Fatal编程技术网

Android 如何制作能够启动我的机器人测试的APK?

Android 如何制作能够启动我的机器人测试的APK?,android,testing,robotium,Android,Testing,Robotium,(A) 要测试的应用程序(如浏览器) (B) 测试应用程序。(扩展活动仪表测试用例2)(Robotium) (C) 发射器(如“devTools”->仪器) 如何创建可以启动测试应用程序(B)的APK(C)。公共类主扩展活动{ 受保护名单; 受保护组件名称mBrowserTestComponent; 受保护的最终静态字符串TARGET_PACKAGE=“com.android.browser”; @凌驾 创建时的公共void(Bundle savedInstanceState){ super.o

(A) 要测试的应用程序(如浏览器)

(B) 测试应用程序。(扩展活动仪表测试用例2)(Robotium)

(C) 发射器(如“devTools”->仪器)

如何创建可以启动测试应用程序(B)的APK(C)。

公共类主扩展活动{
受保护名单;
受保护组件名称mBrowserTestComponent;
受保护的最终静态字符串TARGET_PACKAGE=“com.android.browser”;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mList=this.getPackageManager().queryInstrumentation(目标_包,0);
mBrowserTestComponent=instrumentationForPosition(0);
}
公共空白起始点(视图){
this.startInstrumentation(mBrowserTestComponent,null,null);
}
公共组件名称instrumentationForPosition(int位置)
{
if(mList==null){
返回null;
}
InstrumentationInfo ii=列表获取(位置);
返回新组件名称(ii.packageName,ii.name);
}
}
参考:
public class Main extends Activity {

protected List<InstrumentationInfo> mList;
protected ComponentName mBrowserTestComponent;
protected final static String TARGET_PACKAGE = "com.android.browser";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mList = this.getPackageManager().queryInstrumentation(TARGET_PACKAGE, 0);
    mBrowserTestComponent = instrumentationForPosition(0);
}

public void startTesting(View view) {
    this.startInstrumentation(mBrowserTestComponent, null, null);
}

public ComponentName instrumentationForPosition(int position)
{
    if (mList == null) {
        return null;
    }
    InstrumentationInfo ii = mList.get(position);
    return new ComponentName(ii.packageName, ii.name);
}
}