/**
* Perform calling of an activitys {@link Activity#onCreate}
* method. The default implementation simply calls through to that method.
*
* @param activity The activity being created.
* @param icicle The previously frozen state (or null) to pass through to
* onCreate().
*/
public void callActivityOnCreate(Activity activity, Bundle icicle) {
...
activity.performCreate(icicle);
...
}从代码可以看到它做的事情也就是直接调用Activity类的performCreate方法: final void performCreate(Bundle icicle) {
onCreate(icicle);
mVisibleFromClient = !mWindow.getWindowStyle().getBoolean(
com.android.internal.R.styleable.Window_windowNoDisplay, false);
而performCreate方法最终调用的就是onCreate方法。robotium注意performCreate这个方法是属于Internal API,它不是public出去给外部使用的.所以这里就好比Instrumentation勾住了本应该系统调用的onCreate方法,然后由用户自己来控制勾住的这个方法什么时候执行。
安卓从Android4.3开始引进了UiAutomation框架来支持通过Accessibility API来实现针对用户界面UI层面的功能测试,Instrumentation也提供了相应的接口来获得UiAutomation实例:
/**
* Gets the {@link UiAutomation} instance.
* <p>
* <strong>Note:</strong> The APIs exposed via the returned {@link UiAutomation}
* work across application boundaries while the APIs exposed by the instrumentation
* do not. For example, {@link Instrumentation#sendPointerSync(MotionEvent)} will
* not allow you to inject the event in an app different from the instrumentation
* target, while {@link UiAutomation#injectInputEvent(android.view.InputEvent, boolean)}
* will work regardless of the current application.
* </p>
* <p>
* A typical test case should be using either the {@link UiAutomation} or
* {@link Instrumentation} APIs. Using both APIs at the same time is not
* a mistake by itself but a client has to be aware of the APIs limitations.
* </p>
* @return The UI automation instance.
*
* @see UiAutomation
*/
public UiAutomation getUiAutomation() {
if (mUiAutomationConnection != null) {
if (mUiAutomation == null) {
mUiAutomation = new UiAutomation(getTargetContext().getMainLooper(),
mUiAutomationConnection);
mUiAutomation.connect();
}
return mUiAutomation;
}
return null;
}关于UiAutomation更多的描述请查看本人上一个系列关于UiAutomator源码分析的文章,这里列出来方便大家浏览:
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-26961-10.html
永世不变苏音么么哒QAQ让我这种耳力特别好的如何生存QuQ
那文笔谁看啊
反过来也可以说就算是老船我们照样没办法