码迷,mamicode.com
首页 > 移动开发 > 详细

Android无线测试之—UiAutomator UiScrollable API介绍二

时间:2015-06-23 19:45:10      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

快速滑动

一、快速滑动相关概念

1、步长:从一点滑动到另一点所用的时间

2、扫动次数:例如列表,要滑动多少次才能到底部,这个滑动次数就是扫动次数

二、相关API

返回值 API 描述
boolean flingBackward() 以步长为5快速向后滑动
boolean filingForward() 以步长为5快速向前滑动
boolean flingToBeginning(int maxSwipes) 自定义扫动次数以步长为5快速滑动到起始
boolean flingToEnd(int maxSwipes) 自定义扫描次数以步长为5快速滑动到末尾

 

 

 

 

 

 

三、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="testFling";
        androidId="1";
        new UiAutomatorHelper(jarName, testClass, testName, androidId);

    }
    
    public void testFling() throws UiObjectNotFoundException{
        UiDevice.getInstance().pressHome();
        sleep(2000);
        
        UiSelector l=new UiSelector().text("People");
        UiObject p=new UiObject(l);
        p.click();
        sleep(2000);
        UiScrollable scroll=new UiScrollable(new UiSelector().className("android.widget.ListView"));
        scroll.flingForward();
        sleep(3000);
        scroll.flingBackward();
        sleep(3000);
        scroll.flingToEnd(5);
        sleep(3000);
        scroll.flingToBeginning(5);
        
    }

}
Demo.java

 

Android无线测试之—UiAutomator UiScrollable API介绍二

标签:

原文地址:http://www.cnblogs.com/fsw-blog/p/4579269.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!