真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Android4.3引入的UiAutomation新框架官方簡(jiǎn)介

譯者序:Google在Android 4.3發(fā)布時(shí)提供了一套新的UiAutomation框架來(lái)支持用戶界面自動(dòng)化測(cè)試,該框架通過(guò)運(yùn)用已有的Accessibility APIs來(lái)模擬用戶跟設(shè)備用戶界面的交互:比如獲取窗口界面控件和注入事件等。如在4.3之前UiAutomator工具是通過(guò)InputManager或者更早的WindowManager來(lái)注入KeyEvent等,4.3之后用的就是新框架UiAutomation使用的Accessibility APIs來(lái)注入事件了。

公司主營(yíng)業(yè)務(wù):做網(wǎng)站、成都網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。成都創(chuàng)新互聯(lián)公司是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。成都創(chuàng)新互聯(lián)公司推出老邊免費(fèi)做網(wǎng)站回饋大家。

Class Overview/概覽


Class for interacting with the device's UI by simulation user actions and introspection of the screen content. It relies on the platform accessibility APIs to introspect the screen and to perform some actions on the remote view tree. It also allows injecting of arbitrary raw input events simulating user interaction with keyboards and touch devices. One can think of a UiAutomation as a special type of AccessibilityService which does not provide hooks for the service life cycle and exposes other APIs that are useful for UI test automation.

這是一個(gè)通過(guò)模擬用戶操作來(lái)與設(shè)備用戶界面交互以及獲取屏幕內(nèi)容的類。它依賴于平臺(tái)的輔助功能APIs來(lái)在遠(yuǎn)程的控件樹上獲取屏幕內(nèi)容以及執(zhí)行一些操作。同時(shí)它也允許通過(guò)注入原生事件(譯者注:指的就是InputEvent. KeyEvent也是繼承于InputEvent的,所以說(shuō)它是原生事件)來(lái)模擬用戶的按鍵和觸屏操作。我們可以認(rèn)為UiAutomation就是一個(gè)特殊類型的AccessibilityService,其既不會(huì)為控制服務(wù)的生命周期而提供鉤子函數(shù),也不會(huì)暴露任何其他可以直接用于用戶界面測(cè)試自動(dòng)化的APIs.

The APIs exposed by this class are low-level to maximize flexibility when developing UI test automation tools and libraries. Generally, a UiAutomation client should be using a higher-level library or implement high-level functions. For example, performing a tap on the screen requires construction and injecting of a touch down and up events which have to be delivered to the system by a call to injectInputEvent(InputEvent, boolean).

這個(gè)類暴露出來(lái)的APIs是很低層的,目的就是為了在開發(fā)用戶界面測(cè)試自動(dòng)化框架和庫(kù)時(shí)提供最大的彈性。總的來(lái)說(shuō),一個(gè)UiAutomation客戶端應(yīng)該使用一些(基于UiAutomation的)更高層次的庫(kù)或者實(shí)現(xiàn)更高層次的方法。比如,模擬一個(gè)用戶在屏幕上的點(diǎn)擊事件需要構(gòu)造并注入一個(gè)按下和一個(gè)彈起事件,然后必須調(diào)用UiAutomation的一個(gè)injectInputEvent(InputEvent, boolean)的調(diào)用來(lái)發(fā)送給操作系統(tǒng)。

The APIs exposed by this class operate across applications enabling a client to write tests that cover use cases spanning over multiple applications. For example, going to the settings application to change a setting and then interacting with another application whose behavior depends on that setting.

這個(gè)類暴露出來(lái)的APIs可以跨應(yīng)用,這樣用戶就可以編寫可以跨越多個(gè)應(yīng)用的測(cè)試用例腳本了。比如,打開系統(tǒng)的設(shè)置應(yīng)用去修改一些設(shè)置然后再與另外一個(gè)依賴于該設(shè)置的應(yīng)用進(jìn)行交互(譯者注:這個(gè)在instrumentation這個(gè)框架可以做不到的)。

Testing and Debugging(來(lái)自android 4.3的APIs官方改動(dòng)文檔)


Automated UI testing/用戶界面測(cè)試自動(dòng)化

The new UiAutomation class provides APIs that allow you to simulate user actions for test automation. By using the platform's AccessibilityService APIs, the UiAutomation APIs allow you to inspect the screen content and inject arbitrary keyboard and touch events.

新的UiAutomation這個(gè)類提供了一系列的APIs來(lái)允許你在測(cè)試自動(dòng)化時(shí)模擬用戶的操作。通過(guò)封裝使用了平臺(tái)上的AccessibilityService  APIs, UiAutomation APIs允許你獲取窗口(控件)內(nèi)容并且注入按鍵和觸屏事件。

To get an instance of UiAutomation, call Instrumentation.getUiAutomation(). In order for this to work, you must supply the -w option with the instrument command when running your InstrumentationTestCase from adb shell.

你可以通過(guò)調(diào)用Instrumentation.getUiAutomation()來(lái)獲得UiAutomation的一個(gè)實(shí)例。為了讓它工作起來(lái),當(dāng)你在adb shell上運(yùn)行你的InstrumentationTestCase的時(shí)候你還需要為instrument命令提供-w這個(gè)選項(xiàng)。

With the UiAutomation instance, you can execute arbitrary events to test your app by callingexecuteAndWaitForEvent(), passing it a Runnable to perform, a timeout period for the operation, and an implementation of the UiAutomation.AccessibilityEventFilter interface. It's within yourUiAutomation.AccessibilityEventFilter implementation that you'll receive a call that allows you to filter the events that you're interested in and determine the success or failure of a given test case.

通過(guò)UiAutomation的實(shí)例,你可以調(diào)用其executeAndWaitForEvent()對(duì)你的應(yīng)用注入不同的事件來(lái)進(jìn)行測(cè)試:該函數(shù)會(huì)接受一個(gè)可執(zhí)行 Runnable線程對(duì)象用來(lái)執(zhí)行事件注入操作,一個(gè)操作超時(shí),以及一個(gè)實(shí)現(xiàn)了UiAutomation.AccessibilityEventFilter的類的實(shí)例。正是在這個(gè)UiAutomation.AccessibilityEventFilter實(shí)現(xiàn)類里面你會(huì)收到一個(gè)回調(diào)來(lái)讓你過(guò)濾那些你喜歡的事件并決定你的測(cè)試用例是否通過(guò)。

To observe all the events during a test, create an implementation of UiAutomation.OnAccessibilityEventListenerand pass it to setOnAccessibilityEventListener(). Your listener interface then receives a call toonAccessibilityEvent() each time an event occurs, receiving an AccessibilityEvent object that describes the event.

如果要在測(cè)試時(shí)監(jiān)控所有的事件,你需要?jiǎng)?chuàng)建一個(gè)UiAutomation.OnAccessibilityEventListener的實(shí)現(xiàn)類然后把它的實(shí)例傳遞給setOnAccessibilityEventListener()。你的監(jiān)聽(tīng)接口將會(huì)在每次有事件觸發(fā)的時(shí)候接收到一個(gè)發(fā)送給onAccessibilityEvent()的回調(diào),里面的參數(shù)就是一個(gè)描述該事件的AccessibilityEvent 的對(duì)象

There is a variety of other operations that the UiAutomation APIs expose at a very low level to encourage the development of UI test tools such as uiautomator. For instance, UiAutomation can also:

 UiAutomation APIs還暴露了很多其他的低層次的操作來(lái)鼓勵(lì)大家去開發(fā)如uiautomator這樣的用戶界面測(cè)試工具。比如UiAutomation還可以做以下事情:

  • Inject input events/注入事件
  • Change the orientation of the screen/改變屏幕的方向
  • Take screenshots/截屏

And most importantly for UI test tools, the UiAutomation APIs work across application boundaries, unlike those inInstrumentation.

最為用戶界面自動(dòng)化測(cè)試工具,最重要的一點(diǎn)是,UiAutomation APIs 可以跨應(yīng)用工作,而不像Instrumentation提供了的那些APIs.


 

作者

自主博客

微信

CSDN

天地會(huì)珠海分舵

http://techgogogo.com


服務(wù)號(hào):TechGoGoGo

掃描碼:

Android4.3引入的UiAutomation新框架官方簡(jiǎn)介

http://weahome.cn/article/gogpds.html

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部

        <tfoot id="04ysm"></tfoot>
        <strike id="04ysm"></strike>
        <strike id="04ysm"></strike>