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


Java UiScrollable.setAsHorizontalList方法代码示例

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


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

示例1: testCalculator

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
public void testCalculator() throws Exception {
    uiDevice.findObject(new UiSelector().descriptionContains("Apps")).clickAndWaitForNewWindow();

    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    appViews.setAsHorizontalList();

    UiObject calculatorApp = appViews.getChildByText(new UiSelector()
            .className(android.widget.TextView.class.getName()), "Calculator");
    calculatorApp.clickAndWaitForNewWindow();

    // Calculator app
    UiObject threeButton = uiDevice.findObject(new UiSelector().text("3"));
    threeButton.click();

    UiObject plusButton = uiDevice.findObject(new UiSelector().text("+"));
    plusButton.click();

    UiObject fiveButton = uiDevice.findObject(new UiSelector().text("5"));
    fiveButton.click();

    UiObject equalsButton = uiDevice.findObject(new UiSelector().text("="));
    equalsButton.click();

    UiObject display = uiDevice.findObject(new UiSelector()
            .resourceId("com.android.calculator2:id/display"));
    UiObject displayNumber = display.getChild(new UiSelector().index(0));

    assertEquals(displayNumber.getText(), "8");

    uiDevice.pressHome();
}
 
开发者ID:Janamou,项目名称:android-testing,代码行数:32,代码来源:AutomatorTest.java

示例2: testBrowserApp

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
public void testBrowserApp() throws Exception {
    uiDevice.findObject(new UiSelector().descriptionContains("Apps")).clickAndWaitForNewWindow();

    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    appViews.setAsHorizontalList();

    UiObject browserApp = appViews.getChildByText(new UiSelector()
            .className(android.widget.TextView.class.getName()), "Browser");
    browserApp.clickAndWaitForNewWindow();

    // Browser App set url
    UiObject urlForm = uiDevice.findObject(new UiSelector()
            .resourceId("com.android.browser:id/url"));
    urlForm.setText("http://www.google.cz");
    //uiDevice.pressKeyCode(KeyEvent.KEYCODE_ENTER);
    uiDevice.pressEnter();

    // Wait to load page
    SystemClock.sleep(10000);

    // Click on webview to lose focus from form
    UiObject webView = uiDevice.findObject(new UiSelector()
            .className("android.webkit.WebView"));
    webView.click();

    uiDevice.pressMenu();

    // Sleep to show the menu
    SystemClock.sleep(1000);
    UiObject refreshButton = uiDevice.findObject(new UiSelector()
            .text("Refresh"));
    refreshButton.click();
}
 
开发者ID:Janamou,项目名称:android-testing,代码行数:34,代码来源:AutomatorTest.java

示例3: testCalculator

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
@Test
public void testCalculator() throws Exception {
    // Home screen apps button
    UiObject appButton = uiDevice.findObject(new UiSelector().descriptionContains("Apps"));
    assertTrue(appButton.exists());

    appButton.clickAndWaitForNewWindow();

    // Scrollable view with apps
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    assertTrue(appViews.exists());

    appViews.setAsHorizontalList();

    // Find calculator application
    UiObject calculatorApp = appViews.getChildByText(new UiSelector()
            .className("android.widget.TextView"), "Calculator");
    assertTrue(calculatorApp.exists());

    calculatorApp.clickAndWaitForNewWindow();

    // Use calculator app
    UiObject clearButton = uiDevice.findObject(new UiSelector().textMatches("clr|del"));
    assertTrue(clearButton.exists());
    clearButton.longClick();

    UiObject threeButton = uiDevice.findObject(new UiSelector().text("3"));
    assertTrue(threeButton.exists());
    threeButton.click();

    UiObject plusButton = uiDevice.findObject(new UiSelector().text("+"));
    assertTrue(plusButton.exists());
    plusButton.click();

    UiObject fiveButton = uiDevice.findObject(new UiSelector().text("5"));
    assertTrue(fiveButton.exists());
    fiveButton.click();

    UiObject equalsButton = uiDevice.findObject(new UiSelector().text("="));
    assertTrue(equalsButton.exists());
    equalsButton.click();

    UiObject display = uiDevice.findObject(new UiSelector()
            .resourceId("com.android.calculator2:id/display"));
    assertTrue(display.exists());

    // Validate
    UiObject displayNumber = display.getChild(new UiSelector().index(0));
    assertTrue(displayNumber.exists());
    assertEquals(displayNumber.getText(), "8");
}
 
开发者ID:Janamou,项目名称:android-testing-codelab,代码行数:52,代码来源:AutomatorTest.java

示例4: testBrowserApp

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
@Test
public void testBrowserApp() throws Exception {
    // Home screen apps button
    UiObject appButton = uiDevice.findObject(new UiSelector().descriptionContains("Apps"));
    assertTrue(appButton.exists());

    appButton.clickAndWaitForNewWindow();

    // Scrollable view with apps
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    assertTrue(appViews.exists());

    appViews.setAsHorizontalList();

    // Find browser application
    UiObject browserApp = appViews.getChildByText(new UiSelector()
            .className("android.widget.TextView"), "Browser");
    assertTrue(browserApp.exists());
    browserApp.clickAndWaitForNewWindow();

    // Browser App set url
    UiObject urlForm = uiDevice.findObject(new UiSelector()
            .resourceId("com.android.browser:id/url"));
    assertTrue(urlForm.exists());
    urlForm.click();
    urlForm.setText("www.google.com");
    uiDevice.pressEnter();

    // Wait to load page
    SystemClock.sleep(10000);

    // Show menu
    uiDevice.pressMenu();

    // Find text on page
    UiObject findButton = uiDevice.findObject(new UiSelector()
            .text("Find on page"));
    assertTrue(findButton.exists());
    findButton.click();

    UiObject findView = uiDevice.findObject(new UiSelector()
            .resourceId("android:id/edit"));
    assertTrue(findView.exists());
    findView.click();
    findView.setText("Google");
    uiDevice.pressEnter();

    SystemClock.sleep(2000);

    // Dismiss search
    UiObject okButtonView = uiDevice.findObject(new UiSelector()
            .resourceId("com.android.browser:id/iconcombo"));
    assertTrue(okButtonView.exists());
    okButtonView.click();
}
 
开发者ID:Janamou,项目名称:android-testing-codelab,代码行数:56,代码来源:AutomatorTest.java

示例5: checkSettings

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

    // Simulate a short press on the HOME button.
    mDevice.pressHome();

    // We’re now in the home screen. Next, we want to simulate
    // a user bringing up the All Apps screen.
    // If you use the uiautomatorviewer tool to capture a snapshot
    // of the Home screen, notice that the All Apps button’s
    // content-description property has the value “Apps”. We can
    // use this property to create a UiSelector to find the button.
    UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));

    // Simulate a click to bring up the All Apps screen.
    allAppsButton.clickAndWaitForNewWindow();

    // In the All Apps screen, the Settings app is located in
    // the Apps tab. To simulate the user bringing up the Apps tab,
    // we create a UiSelector to find a tab with the text
    // label “Apps”.
    UiObject appsTab = new UiObject(new UiSelector().text("Apps"));

    // Simulate a click to enter the Apps tab.
    appsTab.click();

    // Next, in the apps tabs, we can simulate a user swiping until
    // they come to the Settings app icon. Since the container view
    // is scrollable, we can use a UiScrollable object.
    UiScrollable appViews = new UiScrollable(
            new UiSelector().scrollable(true));

    // Set the swiping mode to horizontal (the default is vertical)
    appViews.setAsHorizontalList();

    // create a UiSelector to find the Settings app and simulate
    // a user click to launch the app.
    UiObject settingsApp = appViews
            .getChildByText(new UiSelector()
                            .className(android.widget.TextView.class.getName()),
                    "Settings");
    settingsApp.clickAndWaitForNewWindow();

    // Validate that the package name is the expected one
    UiObject settingsValidation = new UiObject(
            new UiSelector()
                    .packageName("com.android.settings"));
    assertThat(settingsValidation.exists(), equalTo(true));
}
 
开发者ID:vogellacompany,项目名称:codeexamples-android,代码行数:50,代码来源:MyUiAutomatorTest.java

示例6: flingBackward

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
/**
 * Performs a backwards fling action with the default number of fling steps (5). If the swipe direction is set to vertical, then the swipe will be performed from top to bottom. If the swipe direction is set to horizontal, then the swipes will be performed from left to right. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew.
 *
 * @param obj        the selector of the scrollable object
 * @param isVertical vertical or horizontal
 * @return true if scrolled, and false if can't scroll anymore
 * @throws android.support.test.uiautomator.UiObjectNotFoundException
 */
@Override
public boolean flingBackward(Selector obj, boolean isVertical) throws UiObjectNotFoundException {
    UiScrollable scrollable = new UiScrollable(obj.toUiSelector());
    if (isVertical) scrollable.setAsVerticalList();
    else scrollable.setAsHorizontalList();
    return scrollable.flingBackward();
}
 
开发者ID:xiaocong,项目名称:android-uiautomator-server,代码行数:16,代码来源:AutomatorServiceImpl.java

示例7: flingForward

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
/**
 * Performs a forward fling with the default number of fling steps (5). If the swipe direction is set to vertical, then the swipes will be performed from bottom to top. If the swipe direction is set to horizontal, then the swipes will be performed from right to left. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew.
 *
 * @param obj        the selector of the scrollable object
 * @param isVertical vertical or horizontal
 * @return true if scrolled, and false if can't scroll anymore
 * @throws android.support.test.uiautomator.UiObjectNotFoundException
 */
@Override
public boolean flingForward(Selector obj, boolean isVertical) throws UiObjectNotFoundException {
    UiScrollable scrollable = new UiScrollable(obj.toUiSelector());
    if (isVertical) scrollable.setAsVerticalList();
    else scrollable.setAsHorizontalList();
    return scrollable.flingForward();
}
 
开发者ID:xiaocong,项目名称:android-uiautomator-server,代码行数:16,代码来源:AutomatorServiceImpl.java

示例8: flingToBeginning

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
/**
 * Performs a fling gesture to reach the beginning of a scrollable layout element. The beginning can be at the top-most edge in the case of vertical controls, or the left-most edge for horizontal controls. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew.
 *
 * @param obj        the selector of the scrollable object
 * @param isVertical vertical or horizontal
 * @param maxSwipes  max swipes to achieve beginning.
 * @return true on scrolled, else false
 * @throws android.support.test.uiautomator.UiObjectNotFoundException
 */
@Override
public boolean flingToBeginning(Selector obj, boolean isVertical, int maxSwipes) throws UiObjectNotFoundException {
    UiScrollable scrollable = new UiScrollable(obj.toUiSelector());
    if (isVertical) scrollable.setAsVerticalList();
    else scrollable.setAsHorizontalList();
    return scrollable.flingToBeginning(maxSwipes);
}
 
开发者ID:xiaocong,项目名称:android-uiautomator-server,代码行数:17,代码来源:AutomatorServiceImpl.java

示例9: flingToEnd

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
/**
 * Performs a fling gesture to reach the end of a scrollable layout element. The end can be at the bottom-most edge in the case of vertical controls, or the right-most edge for horizontal controls. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew.
 *
 * @param obj        the selector of the scrollable object
 * @param isVertical vertical or horizontal
 * @param maxSwipes  max swipes to achieve end.
 * @return true on scrolled, else false
 * @throws android.support.test.uiautomator.UiObjectNotFoundException
 */
@Override
public boolean flingToEnd(Selector obj, boolean isVertical, int maxSwipes) throws UiObjectNotFoundException {
    UiScrollable scrollable = new UiScrollable(obj.toUiSelector());
    if (isVertical) scrollable.setAsVerticalList();
    else scrollable.setAsHorizontalList();
    return scrollable.flingToEnd(maxSwipes);
}
 
开发者ID:xiaocong,项目名称:android-uiautomator-server,代码行数:17,代码来源:AutomatorServiceImpl.java

示例10: scrollBackward

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
/**
 * Performs a backward scroll. If the swipe direction is set to vertical, then the swipes will be performed from top to bottom. If the swipe direction is set to horizontal, then the swipes will be performed from left to right. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew.
 *
 * @param obj        the selector of the scrollable object
 * @param isVertical vertical or horizontal
 * @param steps      number of steps. Use this to control the speed of the scroll action.
 * @return true if scrolled, false if can't scroll anymore
 * @throws android.support.test.uiautomator.UiObjectNotFoundException
 */
@Override
public boolean scrollBackward(Selector obj, boolean isVertical, int steps) throws UiObjectNotFoundException {
    UiScrollable scrollable = new UiScrollable(obj.toUiSelector());
    if (isVertical) scrollable.setAsVerticalList();
    else scrollable.setAsHorizontalList();
    return scrollable.scrollBackward(steps);
}
 
开发者ID:xiaocong,项目名称:android-uiautomator-server,代码行数:17,代码来源:AutomatorServiceImpl.java

示例11: scrollForward

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
/**
 * Performs a forward scroll with the default number of scroll steps (55). If the swipe direction is set to vertical, then the swipes will be performed from bottom to top. If the swipe direction is set to horizontal, then the swipes will be performed from right to left. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew.
 *
 * @param obj        the selector of the scrollable object
 * @param isVertical vertical or horizontal
 * @param steps      number of steps. Use this to control the speed of the scroll action.
 * @return true on scrolled, else false
 * @throws android.support.test.uiautomator.UiObjectNotFoundException
 */
@Override
public boolean scrollForward(Selector obj, boolean isVertical, int steps) throws UiObjectNotFoundException {
    UiScrollable scrollable = new UiScrollable(obj.toUiSelector());
    if (isVertical) scrollable.setAsVerticalList();
    else scrollable.setAsHorizontalList();
    return scrollable.scrollForward(steps);
}
 
开发者ID:xiaocong,项目名称:android-uiautomator-server,代码行数:17,代码来源:AutomatorServiceImpl.java

示例12: scrollToBeginning

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
/**
 * Scrolls to the beginning of a scrollable layout element. The beginning can be at the top-most edge in the case of vertical controls, or the left-most edge for horizontal controls. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew.
 *
 * @param obj        the selector of the scrollable object
 * @param isVertical vertical or horizontal
 * @param maxSwipes  max swipes to be performed.
 * @param steps      use steps to control the speed, so that it may be a scroll, or fling
 * @return true on scrolled else false
 * @throws android.support.test.uiautomator.UiObjectNotFoundException
 */
@Override
public boolean scrollToBeginning(Selector obj, boolean isVertical, int maxSwipes, int steps) throws UiObjectNotFoundException {
    UiScrollable scrollable = new UiScrollable(obj.toUiSelector());
    if (isVertical) scrollable.setAsVerticalList();
    else scrollable.setAsHorizontalList();
    return scrollable.scrollToBeginning(maxSwipes, steps);
}
 
开发者ID:xiaocong,项目名称:android-uiautomator-server,代码行数:18,代码来源:AutomatorServiceImpl.java

示例13: scrollToEnd

import android.support.test.uiautomator.UiScrollable; //导入方法依赖的package包/类
/**
 * Scrolls to the end of a scrollable layout element. The end can be at the bottom-most edge in the case of vertical controls, or the right-most edge for horizontal controls. Make sure to take into account devices configured with right-to-left languages like Arabic and Hebrew.
 *
 * @param obj        the selector of the scrollable object
 * @param isVertical vertical or horizontal
 * @param maxSwipes  max swipes to be performed.
 * @param steps      use steps to control the speed, so that it may be a scroll, or fling
 * @return true on scrolled, else false
 * @throws android.support.test.uiautomator.UiObjectNotFoundException
 */
@Override
public boolean scrollToEnd(Selector obj, boolean isVertical, int maxSwipes, int steps) throws UiObjectNotFoundException {
    UiScrollable scrollable = new UiScrollable(obj.toUiSelector());
    if (isVertical) scrollable.setAsVerticalList();
    else scrollable.setAsHorizontalList();
    return scrollable.scrollToEnd(maxSwipes, steps);
}
 
开发者ID:xiaocong,项目名称:android-uiautomator-server,代码行数:18,代码来源:AutomatorServiceImpl.java

示例14: 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.setAsHorizontalList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。