zoukankan      html  css  js  c++  java
  • Android无线测试之—UiAutomator UiScrollable API介绍五

    滑动区域校准常量设置与获取

    一、校准概念

    校准常量指的是:滑动操作坐标时的偏移量,用来取偏移比例

    二、相关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
  • 相关阅读:
    ESXi创建磁盘命令
    TNS-12518,TNS-12536,TNS-00506,Linux Error: 11: Resource temporarily unavailable
    监听的instance status blocked分析
    Oracle 用户、对象权限、系统权限
    MIME详解
    11g等待事件之library cache: mutex X
    Latch Free
    PowerDesigner小技巧
    yum本地源配置
    内核参数SEMMSL SEMMNS SEMOPM SEMMNI参数的设置
  • 原文地址:https://www.cnblogs.com/fsw-blog/p/4597430.html
Copyright © 2011-2022 走看看