Android4.3引入的UiAutomation新架構官方簡介,uiautomation
譯者序:Google在Android 4.3發布時提供了一套新的UiAutomation架構來支援使用者介面自動化測試,該架構通過運用已有的Accessibility APIs來類比使用者跟裝置使用者介面的互動:比如擷取視窗介面控制項和注入事件等。如在4.3之前UiAutomator工具是通過InputManager或者更早的WindowManager來注入KeyEvent等,4.3之後用的就是新架構UiAutomation使用的Accessibility APIs來注入事件了。
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.
這是一個通過類比使用者操作來與裝置使用者介面互動以及擷取螢幕內容的類。它依賴於平台的協助工具功能APIs來在遠端控制項樹上擷取螢幕內容以及執行一些操作。同時它也允許通過注入原生事件(譯者注:指的就是InputEvent. KeyEvent也是繼承於InputEvent的,所以說它是原生事件)來類比使用者的按鍵和觸屏操作。我們可以認為UiAutomation就是一個特殊類型的AccessibilityService,其既不會為控制服務的生命週期而提供鉤子函數,也不會暴露任何其他可以直接用於使用者介面測試自動化的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)
.
這個類暴露出來的APIs是很低層的,目的就是為了在開發使用者介面測試自動化架構和庫時提供最大的彈性。總的來說,一個UiAutomation用戶端應該使用一些(基於UiAutomation的)更高層次的庫或者實現更高層次的方法。比如,類比一個使用者在螢幕上的點擊事件需要構造並注入一個按下和一個彈起事件,然後必須調用UiAutomation的一個injectInputEvent(InputEvent, boolean)的調用來發送給作業系統。
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.
這個類暴露出來的APIs可以跨應用,這樣使用者就可以編寫可以跨越多個應用的測試案例指令碼了。比如,開啟系統的設定應用去修改一些設定然後再與另外一個依賴於該設定的應用進行互動(譯者註:這個在instrumentation這個架構可以做不到的)。
Testing and Debugging(來自android 4.3的APIs官方改動文檔)
Automated UI testing/使用者介面測試自動化
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這個類提供了一系列的APIs來允許你在測試自動化時類比使用者的操作。通過封裝使用了平台上的AccessibilityService APIs, UiAutomation
APIs允許你擷取視窗(控制項)內容並且注入按鍵和觸屏事件。
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
.
你可以通過調用Instrumentation.getUiAutomation()來獲得UiAutomation的一個執行個體。為了讓它工作起來,當你在adb shell上運行你的InstrumentationTestCase的時候你還需要為instrument命令提供-w這個選項。
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.
通過UiAutomation的執行個體,你可以調用其executeAndWaitForEvent()對你的應用注入不同的事件來進行測試:該函數會接受一個可執行 Runnable線程對象用來執行事件注入操作,一個操作逾時,以及一個實現了UiAutomation.AccessibilityEventFilter的類的執行個體。正是在這個UiAutomation.AccessibilityEventFilter實作類別裡面你會收到一個回調來讓你過濾那些你喜歡的事件並決定你的測試案例是否通過。
To observe all the events during a test, create an implementation of UiAutomation.OnAccessibilityEventListener
and 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.
如果要在測試時監控所有的事件,你需要建立一個UiAutomation.OnAccessibilityEventListener的實作類別然後把它的執行個體傳遞給setOnAccessibilityEventListener()。你的監聽介面將會在每次有事件觸發的時候接收到一個發送給onAccessibilityEvent()的回調,裡面的參數就是一個描述該事件的AccessibilityEvent
的對象
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還暴露了很多其他的低層次的操作來鼓勵大家去開發如uiautomator這樣的使用者介面測試載入器。比如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
.
最為使用者介面自動化測試載入器,最重要的一點是,UiAutomation
APIs 可以跨應用工作,而不像Instrumentation提供了的那些APIs.
誰有適用於Android43的Google服務架構
請問你的手機root過麼?如果想玩遊戲的話還是建議root後刷入Google服務包
三星i9500 android43更新不了
您好:
如需升級,您可以:1、通過手機中的系統更新:skp.samsungcsportal.com/...te=cn2、通過Kies軟體升級手機:skp.samsungcsportal.com/...103163、將手機送到三星服務中心,由工程師協助升級手機。相關三星指定授權服務中心資訊:服務中心查詢請點擊以下連結:www.samsung.com/...120522
歡迎訪問三星關懷:
support.samsung.com.cn/app-cares
三星數字服務...[官方認證]