1, 测试案例
如下是一个简单的测试案例代码,模拟了点击Home键回到主屏,然后点击所以应用按钮打开所有应用列表,
并滚动到时钟应用。打开时钟应用 并选择闹铃界面的第一个闹钟设置,修改该设置的开关。
然后返回到时钟界面再进入倒计时界面。
import android.widget.ListView;
import android.widget.Switch;
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 LaunchSettings extends UiAutomatorTestCase { // 继承UiAutomatorTestCase类
public void testDemo() throws UiObjectNotFoundException {
// 模拟 HOME 键点击事件
getUiDevice().pressHome();
// 现在打开了主屏应用,模拟点击所有应用按钮操作来启动所有应用界面。
// 如果你使用了uiautomatorviewer来查看主屏,则可以发现“所有应用”按钮的
// content-description 属性为“Apps”。可以使用该属性来找到该按钮。
UiObject allAppsButton = new UiObject(new UiSelector().d