Android無線測試之—UiAutomator UiScrollable API介紹五

來源:互聯網
上載者:User

標籤:

滑動地區校準常量設定與擷取

一、校準概念

校準常量指的是:滑動操作座標時的位移量,用來取位移比例

二、相關API

傳回值 API 描述
double getSwipeDeadZonePercentage() 擷取無接觸區百分比的值,預設常量值為0.1,即10%
UiScrollable setSwipeDeadZonePercentage(double swipeDeadZonePercentage) 設定一個組件的大小,在滑動時,視為無接觸區的百分比。

 

 

 

 

三、API應用舉例

package com.testuiselector;import com.android.uiautomator.core.UiDevice;import com.android.uiautomator.core.UiObject;import com.android.uiautomator.core.UiObjectNotFoundException;import com.android.uiautomator.core.UiScrollable;import com.android.uiautomator.core.UiSelector;import com.android.uiautomator.testrunner.UiAutomatorTestCase;public class Demo extends UiAutomatorTestCase {    /**     * @param args     */    public static void main(String[] args) {                String jarName, testClass, testName, androidId;        jarName="demo2";        testClass="com.testuiselector.Demo";        testName="testSwipeDeadZonePercentage";        androidId="1";        new UiAutomatorHelper(jarName, testClass, testName, androidId);    }        public void testSwipeDeadZonePercentage() throws UiObjectNotFoundException{        UiDevice.getInstance().pressHome();        sleep(1000);                UiObject people=new UiObject(new UiSelector().text("People"));        people.clickAndWaitForNewWindow();        UiScrollable scroll=new UiScrollable(new UiSelector().className("android.widget.ListView"));                scroll.flingForward();        System.out.println("滑動時,無接觸區百分比: "+scroll.getSwipeDeadZonePercentage());                //滑動時,無接觸地區百分比設定為50%時,基本沒有滑動,因此這個滑動操作成了一個一點擊操作        scroll.setSwipeDeadZonePercentage(0.5);        scroll.flingForward();            System.out.println("滑動時,無接觸區百分比: "+scroll.getSwipeDeadZonePercentage());    }}
Demo.java

 

Android無線測試之—UiAutomator UiScrollable API介紹五

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.