当前位置: 首页>>代码示例>>Java>>正文


Java Until类代码示例

本文整理汇总了Java中android.support.test.uiautomator.Until的典型用法代码示例。如果您正苦于以下问题:Java Until类的具体用法?Java Until怎么用?Java Until使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Until类属于android.support.test.uiautomator包,在下文中一共展示了Until类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startMainActivityFromHomeScreen

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Before
public void startMainActivityFromHomeScreen() throws Exception {
    // Initialize UiDevice instance
    mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    // Start from the home screen
    mDevice.pressHome();

    // Wait for launcher
    final String launcherPackage = mDevice.getLauncherPackageName();
    assertThat(launcherPackage, notNullValue());
    mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)),
            LAUNCH_TIMEOUT);

    // Launch the blueprint app
    Context context = InstrumentationRegistry.getContext();
    final Intent intent = context.getPackageManager().getLaunchIntentForPackage(BASIC_PACKAGE);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);    // Clear out any previous instances
    context.startActivity(intent);
    // Wait for the app to appear
    mDevice.wait(Until.hasObject(By.pkg(BASIC_PACKAGE).depth(0)), LAUNCH_TIMEOUT);
}
 
开发者ID:fantasy1022,项目名称:FancyTrendView,代码行数:22,代码来源:GoogleTrendActivityUiAutomatorTest.java

示例2: startMainActivityFromHomeScreen

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Before
public void startMainActivityFromHomeScreen() {
    // Initialize UiDevice instance
    mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());

    // Start from the home screen
    mDevice.pressHome();

    // Wait for launcher
    final String launcherPackage = getLauncherPackageName();
    assertThat(launcherPackage, notNullValue());
    mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT);

    // Launch the blueprint app
    Context context = InstrumentationRegistry.getContext();
    final Intent intent = context.getPackageManager()
            .getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);    // Clear out any previous instances
    context.startActivity(intent);

    // Wait for the app to appear
    mDevice.wait(Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)), LAUNCH_TIMEOUT);
}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:24,代码来源:ExampleInstrumentedTest.java

示例3: startMainActivityFromHomeScreen

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Before
public void startMainActivityFromHomeScreen() {
    // Initialize UiDevice instance
    mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());

    // Start from the home screen
    mDevice.pressHome();

    // Wait for launcher
    final String launcherPackage = mDevice.getLauncherPackageName();
    Assert.assertThat(launcherPackage, CoreMatchers.notNullValue());
    mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)),
            LAUNCH_TIMEOUT);

    // Launch the app
    Context context = InstrumentationRegistry.getContext();
    final Intent intent = context.getPackageManager()
            .getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE);
    // Clear out any previous instances
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    context.startActivity(intent);

    // Wait for the app to appear
    mDevice.wait(Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)),
            LAUNCH_TIMEOUT);
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:27,代码来源:UIAnimatorTest.java

示例4: test007CheckEnterAdvPass

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Category(CategorySettingsTests.class)
@Test
public void test007CheckEnterAdvPass() {
    if("V1".equals(Build.MODEL) || "P1".equals(Build.MODEL)) {
        screenshotCap("setting_interface");
        UiObject2 wifiops = device.findObject(By.text("WLAN"));
        wifiops.clickAndWait(Until.newWindow(), LONG_WAIT);
        screenshotCap("wifi_interface");
        sleep(SHORT_SLEEP);
        UiObject2 moreBtn = device.findObject(By.clazz("android.widget.ImageButton").desc("更多选项"));
        moreBtn.click();
        sleep(SHORT_SLEEP);
        UiObject2 addNetworkObj = device.findObject(By.text("高级"));
        addNetworkObj.clickAndWait(Until.newWindow(), LONG_WAIT);
        sleep(SHORT_SLEEP);
        UiObject2 advWLANObj = device.findObject(By.text("高级WLAN"));
        Assert.assertNotNull("没有能够进入到高级WLAN页面", advWLANObj);
    }
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:20,代码来源:SunmiSettings.java

示例5: test012CheckIbeacon

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Test
public void test012CheckIbeacon() {
    if("V1".equals(Build.MODEL) || "P1".equals(Build.MODEL)) {
        screenshotCap("after_enter");
        UiObject2 moreObj = device.findObject(By.text("更多"));
        moreObj.clickAndWait(Until.newWindow(), LONG_WAIT);
        UiObject2 ibeaconObj = device.findObject(By.text("iBeacon"));
        ibeaconObj.clickAndWait(Until.newWindow(), LONG_WAIT);
        UiObject2 ibeaconTitle = device.findObject(By.res("com.sunmi.ibeacon:id/text").text("IBEACON"));
        Assert.assertNotNull("未找到IBEANCON标题", ibeaconTitle);
        UiObject2 ibeaconSwitch = device.findObject(By.res("com.sunmi.ibeacon:id/swi"));
        Assert.assertTrue("iBeacon开关没有打开", ibeaconSwitch.isChecked());
        //检查默认的ibeacon参数
        UiObject2 defaultIbeaconUUIDObj = device.findObject(By.res("com.sunmi.ibeacon:id/tv_uuid").text("FDA50693-A4E2-4FB1-AFCF-C6EB07647825"));
        UiObject2 defaultIbeaconMAJORObj = device.findObject(By.res("com.sunmi.ibeacon:id/tv_major").text("10073"));
        UiObject2 defaultIbeaconMINORObj = device.findObject(By.res("com.sunmi.ibeacon:id/tv_minor").text("61418"));
        Assert.assertNotNull("默认UUID不正确", defaultIbeaconUUIDObj);
        Assert.assertNotNull("默认MAJRO不正确", defaultIbeaconMAJORObj);
        Assert.assertNotNull("默认MINOR不正确", defaultIbeaconMINORObj);
    }
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:22,代码来源:SunmiSettings.java

示例6: test014CheckNetShareStatus

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Test
public void test014CheckNetShareStatus() {
    if("V1".equals(Build.MODEL) || "P1".equals(Build.MODEL)) {
        screenshotCap("after_enter");
        UiObject2 moreObj = device.findObject(By.text("更多"));
        moreObj.clickAndWait(Until.newWindow(), LONG_WAIT);
        UiObject2 APObj = device.findObject(By.text("网络共享与便携式热点"));
        APObj.clickAndWait(Until.newWindow(), LONG_WAIT);
        UiObject2 USBObj = device.findObject(By.text("USB网络共享")).getParent().getParent().findObject(By.res("android:id/switchWidget"));
        UiObject2 WLANObj = device.findObject(By.text("便携式WLAN热点")).getParent().getParent().findObject(By.res("android:id/switchWidget"));
        UiObject2 BTObj = device.findObject(By.text("蓝牙网络共享")).getParent().getParent().findObject(By.res("android:id/switchWidget"));
        Assert.assertFalse("USB网络共享默认不是关闭", USBObj.isChecked());
        Assert.assertFalse("便携式WLAN热点默认不是关闭", WLANObj.isChecked());
        Assert.assertFalse("蓝牙网络共享默认不是关闭", BTObj.isChecked());
    }
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:17,代码来源:SunmiSettings.java

示例7: test015CheckAP

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Test
public void test015CheckAP() {
    if("V1".equals(Build.MODEL) || "P1".equals(Build.MODEL)) {
        screenshotCap("after_enter");
        UiObject2 moreObj = device.findObject(By.text("更多"));
        moreObj.clickAndWait(Until.newWindow(), LONG_WAIT);
        UiObject2 APObj = device.findObject(By.text("网络共享与便携式热点"));
        APObj.clickAndWait(Until.newWindow(), LONG_WAIT);
        UiObject2 WLANObj = device.findObject(By.text("设置WLAN热点"));
        WLANObj.clickAndWait(Until.newWindow(), LONG_WAIT);
        UiObject2 ssidObj = device.findObject(By.res("com.android.settings:id/ssid"));
        ssidObj.clear();
        ssidObj.setText("SUNMITEST");
        UiObject2 pwdObj = device.findObject(By.res("com.android.settings:id/password"));
        pwdObj.clear();
        pwdObj.setText("12345678");
        UiObject2 saveObj = device.findObject(By.res("android:id/button1"));
        saveObj.clickAndWait(Until.newWindow(), LONG_WAIT);
        UiObject2 APInfoObj = device.findObject(By.text("SUNMITEST WPA2 PSK便携式WLAN热点"));
        Assert.assertNotNull("未找到设置的SUNMITEST便携式热点", APInfoObj);
    }
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:23,代码来源:SunmiSettings.java

示例8: test018CheckSleepTimeOut

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Test
//检查显示下休眠时间正确(T1)
public void test018CheckSleepTimeOut() throws UiObjectNotFoundException {
    screenshotCap("after_enter");
    TestUtils.enterSettingsFirstLevelByName("显示");
    UiObject2 sleepTimeObj = device.findObject(By.text("休眠")).getParent().findObject(By.res("android:id/summary"));
    String sleepTime = sleepTimeObj.getText();
    Assert.assertEquals("期望是无操作1周后,而实际是" + sleepTime, "无操作1周后", sleepTime);
    sleep(SHORT_SLEEP);
    sleepTimeObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    UiObject2 sleepOpt = device.findObject(By.checked(true));
    String sleepTime1 = sleepOpt.getText();
    Assert.assertEquals("期望是1周,而实际是" + sleepTime1, "1周", sleepTime1);
    sleep(SHORT_SLEEP);
    UiObject2 fiveMinObj = device.findObject(By.text("5分钟"));
    fiveMinObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    UiObject2 sleepTimeObj1 = device.findObject(By.text("休眠")).getParent().findObject(By.res("android:id/summary"));
    String sleepTime2 = sleepTimeObj1.getText();
    Assert.assertEquals("期望是无操作5分钟后,而实际是" + sleepTime, "无操作5分钟后", sleepTime2);
    sleep(SHORT_SLEEP);
    sleepTimeObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    UiObject2 oneWeekObj = device.findObject(By.text("1周"));
    oneWeekObj.click();
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:25,代码来源:SunmiSettings.java

示例9: test019CheckFont

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Test
//检查显示下字体大小正确(T1)
public void test019CheckFont() throws UiObjectNotFoundException {
    screenshotCap("after_enter");
    TestUtils.enterSettingsFirstLevelByName("显示");
    UiObject2 fontObj = device.findObject(By.text("字体大小")).getParent().findObject(By.res("android:id/summary"));
    String fontSize = fontObj.getText();
    Assert.assertEquals("期望是正常,而实际是" + fontSize, "正常", fontSize);
    sleep(SHORT_SLEEP);
    fontObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    UiObject2 fontOpt = device.findObject(By.checked(true));
    String fontSize1 = fontOpt.getText();
    Assert.assertEquals("期望是正常,而实际是" + fontSize1, "正常", fontSize1);
    sleep(SHORT_SLEEP);
    UiObject2 hugeObj = device.findObject(By.text("超大"));
    hugeObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    sleep(SHORT_SLEEP);
    UiObject2 fontObj1 = device.findObject(By.text("字体大小")).getParent().findObject(By.res("android:id/summary"));
    String fontSize2 = fontObj1.getText();
    Assert.assertEquals("期望是超大,而实际是" + fontSize2, "超大", fontSize2);
    sleep(SHORT_SLEEP);
    fontObj1.clickAndWait(Until.newWindow(), LONG_WAIT);
    UiObject2 normalObj = device.findObject(By.text("正常"));
    normalObj.click();
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:26,代码来源:SunmiSettings.java

示例10: test043CheckAPDefaultName

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Test
public void test043CheckAPDefaultName(){
    if("P1".equals(Build.MODEL)) {
        device.findObject(By.text("更多")).clickAndWait(Until.newWindow(), 5000);
        screenshotCap("更多界面显示");
        device.findObject(By.text("网络共享与便携式热点")).clickAndWait(Until.newWindow(), 5000);
        device.findObject(By.text("WLAN 热点")).clickAndWait(Until.newWindow(), 5000);
        device.findObject(By.text("设置WLAN热点")).clickAndWait(Until.newWindow(), 5000);
        sleep(1000);
        UiObject2 WlanNameObj = device.findObject(By.text("SunmiP1"));
        screenshotCap("设置WLAN界面");
        Assert.assertNotNull("测试失败,默认名称不是SunmiP1", WlanNameObj);
    }
    else if ("V1".equals(Build.MODEL)){

    }
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:18,代码来源:SunmiSettings.java

示例11: test011ClickHotSearchApp

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Category(CategoryAppStoreTests_v3_3_15.class)
@Test
public void test011ClickHotSearchApp(){
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 searchObj = device.findObject(By.res("woyou.market:id/tv_search").text("搜索"));
    searchObj.click();
    TestUtils.screenshotCap("afterClickSearchBar");
    TestUtils.sleep(SHORT_SLEEP);
    int hotAppCount = device.findObject(By.res("woyou.market:id/grid_view")).getChildCount();
    if(hotAppCount != 0){
        String appName = device.findObject(By.res("woyou.market:id/grid_view")).findObject(By.res("woyou.market:id/tv_name")).getText();
        UiObject2 hotSearchObj = device.findObject(By.res("woyou.market:id/grid_view")).findObject(By.res("woyou.market:id/item_app"));
        hotSearchObj.clickAndWait(Until.newWindow(),LONG_WAIT);
        TestUtils.screenshotCap("clickHotsearchFirstOne");
        UiObject2 appDetailObj = device.findObject(By.res("woyou.market:id/tv_name"));
        String appDetailName = appDetailObj.getText();
        Assert.assertEquals(appName,appDetailName);
    }else{
        Assert.fail("没有任何热搜应用,需要确定是否确实不存在热搜应用");
    }
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:22,代码来源:SunmiAppStore_v3_3_15.java

示例12: test020EnterFeedback

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Category(CategoryAppStoreTests_v3_3_15.class)
    @Test
    public void test020EnterFeedback() throws UiObjectNotFoundException {
        TestUtils.screenshotCap("appStoreHome");
        UiObject2 mineEntrence = device.findObject(By.res("woyou.market:id/fab_me"));
        mineEntrence.clickAndWait(Until.newWindow(),LONG_WAIT);
        TestUtils.screenshotCap("mineHome");
        UiScrollable mineScroll = new UiScrollable(new UiSelector().className("android.widget.ScrollView"));
        mineScroll.scrollTextIntoView("反馈");
        TestUtils.screenshotCap("ScrollToFeedbackInterface");
        UiObject2 feedbackObj = device.findObject(By.text("反馈"));
        feedbackObj.clickAndWait(Until.newWindow(),LONG_WAIT);
        TestUtils.screenshotCap("enterFeedbackInterface");
        String currentPkgName = device.getCurrentPackageName();
//        for (int i = 0; i <10 ; i++) {
//            Log.v("myautotest1",device.getCurrentPackageName());
//            sleep(500);
//        }
        Assert.assertEquals("期望当前包名为com.sunmi.userfeedback,而实际为"+currentPkgName,"com.sunmi.userfeedback",currentPkgName);
    }
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:21,代码来源:SunmiAppStore_v3_3_15.java

示例13: test024CommentBeforeInstall

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Category(CategoryAppStoreTests_v3_3_15.class)
@Test
public void test024CommentBeforeInstall() throws IOException, UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotObj = device.findObject(By.res("woyou.market:id/tv_hot_all").text("全部"));
    hotObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    TestUtils.screenshotCap("hotAllInterface");
    UiScrollable hotAllScroll = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    hotAllScroll.scrollIntoView(new UiSelector().resourceId("woyou.market:id/id_tv_install_view").text("安装"));
    TestUtils.screenshotCap("scrollInstallBtnInterface");
    UiObject2 installObj = device.findObject(By.res("woyou.market:id/id_tv_install_view").text("安装"));
    UiObject2 fullAppObj = installObj.getParent().getParent();
    fullAppObj.clickAndWait(Until.newWindow(),LONG_WAIT);
    TestUtils.screenshotCap("uninstalledAppDetail");
    UiObject2 commentObj = device.findObject(By.res("woyou.market:id/tv_install_comment_app"));
    commentObj.clickAndWait(Until.newWindow(),LONG_WAIT);
    TestUtils.screenshotCap("afterClickComment");
    UiObject2 rateObj = device.findObject(By.res("woyou.market:id/rating_bar"));
    Assert.assertNull(rateObj);
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:21,代码来源:SunmiAppStore_v3_3_15.java

示例14: test025CommentAfterInstall

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Category(CategoryAppStoreTests_v3_3_15.class)
@Test
public void test025CommentAfterInstall() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotObj = device.findObject(By.res("woyou.market:id/tv_hot_all").text("全部"));
    hotObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    TestUtils.screenshotCap("hotAllInterface");
    UiScrollable hotAllScroll = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    hotAllScroll.scrollIntoView(new UiSelector().resourceId("woyou.market:id/id_tv_install_view").text("打开"));
    UiObject2 installObj = device.findObject(By.res("woyou.market:id/id_tv_install_view").text("打开"));
    UiObject2 fullAppObj = installObj.getParent().getParent();
    fullAppObj.clickAndWait(Until.newWindow(),LONG_WAIT);
    TestUtils.screenshotCap("enterAppDetail");
    UiObject2 commentObj = device.findObject(By.res("woyou.market:id/tv_install_comment_app"));
    commentObj.clickAndWait(Until.newWindow(),LONG_WAIT);
    device.wait(Until.hasObject(By.res("woyou.market:id/rating_bar")),LONG_WAIT);
    TestUtils.screenshotCap("afterClickComment");
    UiObject2 rateObj = device.findObject(By.res("woyou.market:id/rating_bar"));
    Assert.assertNotNull(rateObj);
    device.pressBack();
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:22,代码来源:SunmiAppStore_v3_3_15.java

示例15: test026FoldupAppDetail

import android.support.test.uiautomator.Until; //导入依赖的package包/类
@Category(CategoryAppStoreTests_v3_3_15.class)
@Test
public void test026FoldupAppDetail() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotObj = device.findObject(By.res("woyou.market:id/tv_hot_all").text("全部"));
    hotObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    TestUtils.screenshotCap("hotAllInterface");
    UiScrollable hotAllScroll = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    UiObject fullAppObj = hotAllScroll.getChild(new UiSelector().className("android.widget.FrameLayout"));
    fullAppObj.clickAndWaitForNewWindow(LONG_WAIT);
    TestUtils.screenshotCap("enterAppDetail");
    UiObject2 foldupButton = device.findObject(By.res("woyou.market:id/iv_arrow"));
    foldupButton.clickAndWait(Until.newWindow(),LONG_WAIT);
    TestUtils.screenshotCap("foldUpAppDetail");
    UiScrollable hotAllScroll1 = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    Assert.assertNotNull(hotAllScroll1);
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:18,代码来源:SunmiAppStore_v3_3_15.java


注:本文中的android.support.test.uiautomator.Until类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。