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


Java UiScrollable.scrollIntoView方法代码示例

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


在下文中一共展示了UiScrollable.scrollIntoView方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: FrenchLocaleTest

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
@Test
public void FrenchLocaleTest() throws InterruptedException, UiObjectNotFoundException {

    UiObject frenchMenuItem = TestHelper.mDevice.findObject(new UiSelector()
            .className("android.widget.TextView")
            .text("Valeur par défaut du système"));
    UiObject englishMenuItem = TestHelper.mDevice.findObject(new UiSelector()
            .className("android.widget.TextView")
            .text("English (United States)"));
    UiObject englishLocaleinFr = TestHelper.mDevice.findObject(new UiSelector()
            .className("android.widget.CheckedTextView")
            .text("English (United States)"));

    /* Go to Settings */
    TestHelper.inlineAutocompleteEditText.waitForExists(waitingTime);

    openSettings();
    LanguageSelection.waitForExists(waitingTime);

    /* system locale is in French, check it is now set to system locale */
    frenchHeading.waitForExists(waitingTime);
    Assert.assertTrue(frenchHeading.exists());
    Assert.assertTrue(frenchMenuItem.exists());
    LanguageSelection.click();
    Assert.assertTrue(sysDefaultLocale.isChecked());

    /* change locale to English in the setting, verify the locale is changed */
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    appViews.scrollIntoView(englishLocaleinFr);
    Assert.assertTrue(englishLocaleinFr.isClickable());
    englishLocaleinFr.click();
    englishHeading.waitForExists(waitingTime);
    Assert.assertTrue(englishHeading.exists());
    Assert.assertTrue(englishMenuItem.exists());
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:36,代码来源:SwitchLocaleTest.java

示例7: EnglishSystemLocaleTest

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
@Test
public void EnglishSystemLocaleTest() throws InterruptedException, UiObjectNotFoundException {

    UiObject frenchMenuItem = TestHelper.mDevice.findObject(new UiSelector()
            .className("android.widget.TextView")
            .text("Français"));
    UiObject englishMenuItem = TestHelper.mDevice.findObject(new UiSelector()
            .className("android.widget.TextView")
            .text("System default"));
    UiObject frenchLocaleinEn = TestHelper.mDevice.findObject(new UiSelector()
            .className("android.widget.CheckedTextView")
            .text("Français"));

    /* Go to Settings */
    TestHelper.inlineAutocompleteEditText.waitForExists(waitingTime);

    openSettings();
    LanguageSelection.waitForExists(waitingTime);

    /* system locale is in English, check it is now set to system locale */
    LanguageSelection.click();
    sysDefaultLocale.waitForExists(waitingTime);
    Assert.assertTrue(sysDefaultLocale.isChecked());

    /* change locale to non-english in the setting, verify the locale is changed */
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    appViews.scrollIntoView(frenchLocaleinEn);
    Assert.assertTrue(frenchLocaleinEn.isClickable());
    frenchLocaleinEn.click();

    frenchHeading.waitForExists(waitingTime);
    Assert.assertTrue(frenchHeading.exists());
    Assert.assertTrue(frenchMenuItem.exists());

    /* Exit to main and see the UI is in French as well */
    TestHelper.pressBackKey();
    UiObject frenchTitle = TestHelper.mDevice.findObject(new UiSelector()
            .className("android.widget.TextView")
            .text("Navigation privée automatique.\nNaviguez. Effacez. Recommencez."));
    frenchTitle.waitForExists(waitingTime);
    Assert.assertTrue(frenchTitle.exists());

    openMenu();
    Assert.assertEquals(TestHelper.settingsMenuItem.getText(), "Paramètres");
    Assert.assertEquals(TestHelper.HelpItem.getText(), "Aide");
    TestHelper.settingsMenuItem.click();

    /* re-enter settings, change it back to system locale, verify the locale is changed */
    LanguageSelection.click();
    Assert.assertTrue(frenchLocaleinEn.isChecked());
    appViews.scrollToBeginning(10);
    sysDefaultLocale.waitForExists(waitingTime);
    sysDefaultLocale.click();
    LanguageSelection.waitForExists(waitingTime);
    Assert.assertTrue(englishHeading.exists());
    Assert.assertTrue(englishMenuItem.exists());
    TestHelper.pressBackKey();
    UiObject englishTitle = TestHelper.mDevice.findObject(new UiSelector()
            .className("android.widget.TextView")
            .text("Automatic private browsing.\nBrowse. Erase. Repeat."));
    englishTitle.waitForExists(waitingTime);
    Assert.assertTrue(englishTitle.exists());
    TestHelper.menuButton.perform(click());
    Assert.assertEquals(TestHelper.settingsMenuItem.getText(), "Settings");
    Assert.assertEquals(TestHelper.HelpItem.getText(), "Help");
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:67,代码来源:SwitchLocaleTest.java

示例8: scrollTo

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
public static void scrollTo(String scrollToString) throws UiObjectNotFoundException {
    // TODO This logic needs to be changed according to the request body from the Driver
    UiScrollable uiScrollable = new UiScrollable(new UiSelector().scrollable(true).instance(0));
    uiScrollable.scrollIntoView(new UiSelector().descriptionContains(scrollToString).instance(0));
    uiScrollable.scrollIntoView(new UiSelector().textContains(scrollToString).instance(0));
}
 
开发者ID:appium,项目名称:appium-uiautomator2-server,代码行数:7,代码来源:Device.java

示例9: scrollTo

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
/**
 * Perform a scroll forward action to move through the scrollable layout element until a visible item that matches the selector is found.
 *
 * @param obj        the selector of the scrollable object
 * @param targetObj  the item matches the selector to be found.
 * @param isVertical vertical or horizontal
 * @return true on scrolled, else false
 * @throws android.support.test.uiautomator.UiObjectNotFoundException
 */
@Override
public boolean scrollTo(Selector obj, Selector targetObj, boolean isVertical) throws UiObjectNotFoundException {
    UiScrollable scrollable = new UiScrollable(obj.toUiSelector());
    if (isVertical) scrollable.setAsVerticalList();
    else scrollable.setAsHorizontalList();
    return scrollable.scrollIntoView(targetObj.toUiSelector());
}
 
开发者ID:xiaocong,项目名称:android-uiautomator-server,代码行数:17,代码来源:AutomatorServiceImpl.java


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