您的位置:首页 > 产品设计 > UI/UE

使用UiAutomator中swipe(Point[], int)方法绘制解锁图案

2015-07-06 11:51 651 查看
swipe(Point[] segments, int segmentSteps)


实现的方法,从point数组中的第一个点滑动到第二个点,第二个点滑动到第三个点,依次滑动,形成一条条折线,每条直线所有步伐segmentSteps

例如:



package com.vv7;

import junit.framework.Assert;

import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;

import android.graphics.Point;
import android.os.RemoteException;

public class UnlockCase extends UiAutomatorTestCase {

public void testUnlockCase() throws RemoteException,
UiObjectNotFoundException {
if (getUiDevice().isScreenOn()) {
getUiDevice().sleep();
}
getUiDevice().wakeUp();// 唤醒屏幕
// 向上滑动,调出图案解锁面板
getUiDevice().swipe(540, 1576, 540, 676, 10);
sleep(3000);
//绘制解锁图案
Point p1 = new Point();
Point p2 = new Point();
Point p3 = new Point();
Point p4 = new Point();
Point p5 = new Point();
p1.x = 215;p1.y = 872;
p2.x = 545;p2.y = 872;
p3.x = 545;p3.y = 1202;
p4.x = 545;p4.y = 1532;
p5.x = 875;p5.y = 1532;
Point[] p = { p1, p2, p3, p4, p5 };
getUiDevice().swipe(p, 40);
sleep(3000);
getUiDevice().pressHome();
UiObject extDateWidget = new UiObject(
new UiSelector()
.resourceId("com.android.deskclock:id/imageview"));
Assert.assertEquals("日期", extDateWidget.getContentDescription());

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: