當前位置: 首頁>>代碼示例>>Java>>正文


Java UiObject.swipeLeft方法代碼示例

本文整理匯總了Java中android.support.test.uiautomator.UiObject.swipeLeft方法的典型用法代碼示例。如果您正苦於以下問題:Java UiObject.swipeLeft方法的具體用法?Java UiObject.swipeLeft怎麽用?Java UiObject.swipeLeft使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.test.uiautomator.UiObject的用法示例。


在下文中一共展示了UiObject.swipeLeft方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: longClickOnArcMenuStartItem

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
/**
 * Tests the long clicks on the floating action button for start in the arc menu
 *
 * <i>A long click on the button to use to start the process should display a snackbar with an explain message</i>
 */
@Test
public void longClickOnArcMenuStartItem(){

    l(this, "@Test longClickOnArcMenuStartItem");

    String expectedText = InstrumentationRegistry.getTargetContext().getString(R.string.info_message_start);

    try {

        /*
         * Display the floating action buttons in the arc menu
         */
        UiObject arcMenu = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH + ":id/fabAction")
        );
        arcMenu.click();
        arcMenu.waitForExists(WAIT_FOR_EXISTS_TIMEOUT);

        /*
         * The floating action button
         */
        UiObject fab = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH+":id/fabStart")
        );
        fab.waitForExists(WAIT_FOR_EXISTS_TIMEOUT);
        assertTrue(fab.isLongClickable());
        fab.swipeLeft(100); //fab.longClick() makes clicks sometimes, so swipeLeft() is a trick to make always a longclick
        UiObject snack = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH + ":id/snackbar_text")
        );

        assertEquals(expectedText, snack.getText());

    } catch ( UiObjectNotFoundException uonfe ){
        uonfe.printStackTrace();
        fail( uonfe.getMessage() );
    }

}
 
開發者ID:pylapp,項目名稱:SmoothClicker,代碼行數:45,代碼來源:ItClickerActivity.java

示例2: longClickOnArcMenuStopItem

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
/**
 * Tests the long clicks on the floating action button for stop in the arc menu
 *
 * <i>A long click on the button to use to stop the process should display a snackbar with an explain message</i>
 */
@Test
public void longClickOnArcMenuStopItem(){

    l(this, "@Test longClickOnArcMenuStopItem");

    String expectedString = InstrumentationRegistry.getTargetContext().getString(R.string.info_message_stop);

    try {

        /*
         * Display the floating action buttons in the arc menu
         */
        UiObject arcMenu = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH + ":id/fabAction")
        );
        arcMenu.click();
        arcMenu.waitForExists(WAIT_FOR_EXISTS_TIMEOUT);

        /*
         * The floating action button
         */
        UiObject fab = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH+":id/fabStop")
        );
        fab.waitForExists(WAIT_FOR_EXISTS_TIMEOUT);
        assertTrue(fab.isLongClickable());
        fab.swipeLeft(100); //fab.longClick() makes clicks sometimes, so swipeLeft() is a trick to make always a longclick
        UiObject snack = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH + ":id/snackbar_text")
        );

        assertEquals(expectedString, snack.getText());

    } catch ( UiObjectNotFoundException uonfe ){
        uonfe.printStackTrace();
        fail( uonfe.getMessage() );
    }

}
 
開發者ID:pylapp,項目名稱:SmoothClicker,代碼行數:45,代碼來源:ItClickerActivity.java

示例3: longClickOnArcMenuSuGrantItem

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
/**
 * Tests the long clicks on the floating action button for SU grant in the arc menu
 *
 * <i>A long click on the button to use to get the SU grant should display a snackbar with an explain message</i>
 */
@Test
public void longClickOnArcMenuSuGrantItem(){

    l(this, "@Test longClickOnArcMenuSuGrantItem");

    String expectedString = InstrumentationRegistry.getTargetContext().getString(R.string.info_message_request_su);

    try {

        /*
         * Display the floating action buttons in the arc menu
         */
        UiObject arcMenu = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH + ":id/fabAction")
        );
        arcMenu.click();
        arcMenu.waitForExists(WAIT_FOR_EXISTS_TIMEOUT);

        /*
         * The floating action button
         */
        UiObject fab = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH+":id/fabRequestSuGrant")
        );
        fab.waitForExists(WAIT_FOR_EXISTS_TIMEOUT);
        assertTrue(fab.isLongClickable());
        fab.swipeLeft(100); //fab.longClick() makes clicks sometimes, so swipeLeft() is a trick to make always a longclick
        UiObject snack = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH + ":id/snackbar_text")
        );

        assertEquals(expectedString, snack.getText());

    } catch ( UiObjectNotFoundException uonfe ){
        uonfe.printStackTrace();
        fail( uonfe.getMessage() );
    }

}
 
開發者ID:pylapp,項目名稱:SmoothClicker,代碼行數:45,代碼來源:ItClickerActivity.java

示例4: swipes

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
/**
 * Tests the left and right swipes on the intro screens
 *
 * <i>A swipe to the right on the first screen does nothing</i>
 * <i>A swipe to the left on the last screen does nothing</i>
 * <i>A swipe on the left on any screens except the first and the least makes the next screen appear</i>
 * <i>A swipe on the right on any screens except the first and the least makes the previous screen appear</i>
 */
//@Test
public void swipes(){

    l(this, "@Test swipes");

    Context context = InstrumentationRegistry.getTargetContext();

    try {

        UiObject viewPager = mDevice.findObject(
                new UiSelector().resourceId(PACKAGE_APP_PATH + ":id/view_pager")
        );

        // Are we in the first screen ?
        testIfSlide(1);

        // Swipe to the right
        viewPager.swipeRight(100);
        testIfSlide(2);

        // Swipe to the left
        viewPager.swipeLeft(100);
        testIfSlide(3);

        // Swipe to the left
        viewPager.swipeLeft(100);
        testIfSlide(4);

        // Swipe to the left
        viewPager.swipeLeft(100);
        testIfSlide(5);

        // Swipe to the left
        viewPager.swipeLeft(100);
        testIfSlide(6);

        // Swipe to the left
        viewPager.swipeLeft(100);
        testIfSlide(7);

        // Swipe to the left
        viewPager.swipeLeft(100);
        testIfSlide(8);

    } catch ( UiObjectNotFoundException uonfe ){
        uonfe.printStackTrace();
        fail( uonfe.getMessage() );
    }

}
 
開發者ID:pylapp,項目名稱:SmoothClicker,代碼行數:59,代碼來源:ItIntroScreensActivity.java


注:本文中的android.support.test.uiautomator.UiObject.swipeLeft方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。