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


Java UiScrollable类代码示例

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


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

示例1: openAppTest

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
@Test
public void openAppTest() throws Exception {
    UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
    mDevice.pressHome();
    // Bring up the default launcher by searching for a UI component
    // that matches the content description for the launcher button.
    UiObject allAppsButton = mDevice
            .findObject(new UiSelector().description("Apps"));

    // Perform a click on the button to load the launcher.
    allAppsButton.clickAndWaitForNewWindow();
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.wbrawner.simplemarkdown", appContext.getPackageName());
    UiScrollable appView = new UiScrollable(new UiSelector().scrollable(true));
    UiSelector simpleMarkdownSelector = new UiSelector().text("Simple Markdown");
    appView.scrollIntoView(simpleMarkdownSelector);
    mDevice.findObject(simpleMarkdownSelector).clickAndWaitForNewWindow();
}
 
开发者ID:wbrawner,项目名称:SimpleMarkdown,代码行数:21,代码来源:MainActivityTests.java

示例2: testB

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
/**
 * 滑动界面,打开About phone选项
 * 测试环境为标准Android 7.1.1版本,不同设备控件查找方式会有不同
 *
 * @throws UiObjectNotFoundException
 */
public void testB() throws UiObjectNotFoundException {
    // 获取设备对象
    Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
    UiDevice uiDevice = UiDevice.getInstance(instrumentation);
    // 获取上下文
    Context context = instrumentation.getContext();

    // 点击Settings按钮
    UiObject uiObject = uiDevice.findObject(new UiSelector().description("Settings"));
    uiObject.click();

    // 滑动列表到最后,点击About phone选项
    UiScrollable settings = new UiScrollable(new UiSelector().className("android.support.v7.widget.RecyclerView"));
    UiObject about = settings.getChildByText(new UiSelector().className("android.widget.LinearLayout"), "About phone");
    about.click();

    // 点击设备返回按钮
    uiDevice.pressBack();
    uiDevice.pressBack();
}
 
开发者ID:alidili,项目名称:Demos,代码行数:27,代码来源:UiTest.java

示例3: test009SearchByTitle

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
@Category(CategoryAppStoreTests_v3_3_15.class)
@Test
public void test009SearchByTitle() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotOne = device.findObject(By.res("woyou.market:id/linear_hot_view")).findObject(By.res("woyou.market:id/tv_name"));
    String targetAppName = hotOne.getText();
    UiObject2 searchObj = device.findObject(By.res("woyou.market:id/tv_search").text("搜索"));
    searchObj.click();
    TestUtils.screenshotCap("afterClickSearchBar");
    TestUtils.sleep(SHORT_SLEEP);
    UiObject2 searchObj1 = device.findObject(By.res("woyou.market:id/et_search").text("搜索").focused(true));
    searchObj1.click();
    searchObj1.setText(targetAppName);
    TestUtils.screenshotCap("inputSearchContent");
    UiScrollable appList = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    UiObject appInfo = appList.getChildByInstance(new UiSelector().className("android.widget.FrameLayout"),0);
    UiObject appNameObj = appInfo.getChild(new UiSelector().resourceId("woyou.market:id/tv_name"));
    Assert.assertEquals(targetAppName,appNameObj.getText());
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:20,代码来源:SunmiAppStore_v3_3_15.java

示例4: test020EnterFeedback

import android.support.test.uiautomator.UiScrollable; //导入依赖的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

示例5: test024CommentBeforeInstall

import android.support.test.uiautomator.UiScrollable; //导入依赖的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

示例6: test025CommentAfterInstall

import android.support.test.uiautomator.UiScrollable; //导入依赖的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

示例7: test026FoldupAppDetail

import android.support.test.uiautomator.UiScrollable; //导入依赖的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

示例8: test009SearchByTitle

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
@Test
public void test009SearchByTitle() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotOne = device.findObject(By.res("woyou.market:id/linear_hot_view")).findObject(By.res("woyou.market:id/tv_name"));
    String targetAppName = hotOne.getText();
    UiObject2 searchObj = device.findObject(By.res("woyou.market:id/tv_search").text("搜索"));
    searchObj.click();
    TestUtils.screenshotCap("afterClickSearchBar");
    TestUtils.sleep(SHORT_SLEEP);
    UiObject2 searchObj1 = device.findObject(By.res("woyou.market:id/et_search").text("搜索").focused(true));
    searchObj1.click();
    searchObj1.setText(targetAppName);
    TestUtils.screenshotCap("inputSearchContent");
    UiScrollable appList = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    UiObject appInfo = appList.getChildByInstance(new UiSelector().resourceId("woyou.market:id/app_view"),0);
    UiObject appNameObj = appInfo.getChild(new UiSelector().resourceId("woyou.market:id/tv_name"));
    Assert.assertEquals("搜索结果列表第一个应用不是"+targetAppName,targetAppName,appNameObj.getText());
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:19,代码来源:SunmiAppStore.java

示例9: test024CommentBeforeInstall

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
@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/tv_install").text("安装"));
    TestUtils.screenshotCap("scrollInstallBtnInterface");
    UiObject2 installObj = device.findObject(By.res("woyou.market:id/tv_install").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,代码行数:20,代码来源:SunmiAppStore.java

示例10: test025CommentAfterInstall

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
@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/tv_install").text("打开"));
    UiObject2 installObj = device.findObject(By.res("woyou.market:id/tv_install").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,代码行数:21,代码来源:SunmiAppStore.java

示例11: test026FoldupAppDetail

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
@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().resourceId("woyou.market:id/app_view"));
    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,代码行数:17,代码来源:SunmiAppStore.java

示例12: mainActivity_changeGridSize

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
@Test
public void mainActivity_changeGridSize() throws Exception {
    UiScrollable recycleView = new UiScrollable(new UiSelector().resourceId("com.fantasyfang.googletrendapp:id/trendRecycleView")
            .className(RecyclerView.class));//recycleView.click();
    UiObject item = recycleView.getChild(new UiSelector().resourceId("com.fantasyfang.googletrendapp:id/googleTrendView"));
    item.click();

    String gridDescription = InstrumentationRegistry.getInstrumentation().getTargetContext().getString(R.string.choose_grid);
    UiObject grid = mDevice.findObject(new UiSelector().descriptionContains(gridDescription));
    grid.click();

    UiObject gridList = mDevice.findObject(new UiSelector().text("2*2"));
    gridList.click();
    mDevice.waitForIdle();
    takeScreenShot("Change_grid_to_2_2.jpg");
    mDevice.pressHome();
    takeScreenShot("Home.jpg");
}
 
开发者ID:fantasy1022,项目名称:FancyTrendView,代码行数:19,代码来源:GoogleTrendActivityUiAutomatorTest.java

示例13: turnOnAccessibilityPermission

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
public static void turnOnAccessibilityPermission() throws UiObjectNotFoundException {
    UiScrollable texterScreen = new UiScrollable(LauncherHelper.LAUNCHER_CONTAINER);
    texterScreen.setAsVerticalList();

    UiObject permission = new UiObject(
            new UiSelector().text("Off"));

    permission.click();

    UiScrollable permissionScreen = new UiScrollable(LauncherHelper.LAUNCHER_CONTAINER);
    permissionScreen.setAsVerticalList();

    UiObject permissionButton = new UiObject(
            new UiSelector().text("OK"));

    permissionButton.click();
}
 
开发者ID:bhubie,项目名称:Expander,代码行数:18,代码来源:TestUtils.java

示例14: clickListViewItem

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
public static boolean clickListViewItem(String name) {
    UiScrollable listView = new UiScrollable(new UiSelector());
    listView.setMaxSearchSwipes(4);
    listView.waitForExists(3000);
    UiObject listViewItem;
    try {
        if (listView.scrollTextIntoView(name)) {
            listViewItem = listView.getChildByText(new UiSelector()
                    .className(TextView.class.getName()), "" + name + "");
            listViewItem.click();
        } else {
            return false;
        }
    } catch (UiObjectNotFoundException e) {
        return false;
    }
    return true;
}
 
开发者ID:akvo,项目名称:akvo-caddisfly,代码行数:19,代码来源:TestUtil.java

示例15: test022Search

import android.support.test.uiautomator.UiScrollable; //导入依赖的package包/类
@Test
public void test022Search() throws UiObjectNotFoundException {
    if("V1".equals(Build.MODEL) || "P1".equals(Build.MODEL)){
        Log.v("myautotest1","233333333");
        UiObject2 searchBtnObj = device.findObject(By.res("com.android.settings:id/search"));
        searchBtnObj.clickAndWait(Until.newWindow(),LONG_WAIT);
        UiObject2 searchTextObj = device.findObject(By.focused(true));
        searchTextObj.setText("W");
        UiScrollable resultScroll = new UiScrollable(new UiSelector().resourceId("com.android.settings:id/list_results"));
        Boolean searched = resultScroll.scrollTextIntoView("WLAN");
        Assert.assertTrue("未搜索到要查找的WLAN",searched);
    }
}
 
开发者ID:sunmiqa,项目名称:SunmiAuto,代码行数:14,代码来源:SunmiSettings.java


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