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


Java Espresso.onView方法代碼示例

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


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

示例1: verifyViewEnabledStates

import android.support.test.espresso.Espresso; //導入方法依賴的package包/類
private static void verifyViewEnabledStates(TestCase test) {
    ViewInteraction[] buttonsInteractions = getButtonInteractions();
    ViewInteraction[] altButtonsInteractions = getAltButtonInteractions();
    for (int digit : test.sequence) {
        buttonsInteractions[digit]
                .check(ViewAssertions.matches(ViewMatchers.isEnabled()))
                .perform(ViewActions.click());
    }
    for (int i = 0; i < 10; i++) {
        buttonsInteractions[i].check(matchesIsEnabled(
                i >= test.numberKeysEnabledStart && i < test.numberKeysEnabledEnd));
        altButtonsInteractions[0].check(matchesIsEnabled(test.leftAltKeyEnabled));
        altButtonsInteractions[1].check(matchesIsEnabled(test.rightAltKeyEnabled));
    }

    Espresso.onView(ViewMatchers.withText(android.R.string.ok))
            .check(matchesIsEnabled(test.okButtonEnabled));

    ViewInteraction backspaceInteraction = Espresso.onView(
            ViewMatchers.withId(R.id.nptp_backspace));
    // Reset after each iteration by backspacing on the button just clicked.
    backspaceInteraction.check(matchesIsEnabled(true))
            .perform(ViewActions.longClick())
            .check(matchesIsEnabled(false));
}
 
開發者ID:philliphsu,項目名稱:NumberPadTimePicker,代碼行數:26,代碼來源:NumberPadTimePickerDialogTest.java

示例2: getButtonInteractions

import android.support.test.espresso.Espresso; //導入方法依賴的package包/類
private static ViewInteraction[] getButtonInteractions() {
    ViewInteraction[] buttonsInteractions = new ViewInteraction[10];
    // We cannot rely on the withDigit() matcher to retrieve these because,
    // after performing a click on a button, the time display will update to
    // take on that button's digit text, and so withDigit() will return a matcher
    // that matches multiple views with that digit text: the button
    // itself and the time display. This will prevent us from performing
    // validation on the same ViewInteractions later.
    buttonsInteractions[0] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text10));
    buttonsInteractions[1] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text0));
    buttonsInteractions[2] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text1));
    buttonsInteractions[3] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text2));
    buttonsInteractions[4] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text3));
    buttonsInteractions[5] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text4));
    buttonsInteractions[6] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text5));
    buttonsInteractions[7] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text6));
    buttonsInteractions[8] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text7));
    buttonsInteractions[9] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text8));
    return buttonsInteractions;
}
 
開發者ID:philliphsu,項目名稱:NumberPadTimePicker,代碼行數:21,代碼來源:NumberPadTimePickerDialogTest.java

示例3: init

import android.support.test.espresso.Espresso; //導入方法依賴的package包/類
@Before
public void init() {

    if (CameraUtils.isCameraAvailable(InstrumentationRegistry.getTargetContext())) {
        mCameraFragmentTestRule.launchActivity(null);
    } else {
        try {
            mCameraFragmentTestRule.launchActivity(null);
            fail("Should not initialize this ImageClassifierFragment if camera not there.");
        } catch (IllegalArgumentException e) {
            //Success
        }
    }

    //Wait for 1200 ms.
    //Wait for the camera to get stable
    Delay.startDelay(1200);
    Delay.stopDelay();
    Espresso.onView(withId(R.id.container));

    mImageClassifierFragment = mCameraFragmentTestRule.getFragment();
}
 
開發者ID:kevalpatel2106,項目名稱:smart-lens,代碼行數:23,代碼來源:ImageClassificationFragmentTest.java

示例4: getAltButtonInteractions

import android.support.test.espresso.Espresso; //導入方法依賴的package包/類
private static ViewInteraction[] getAltButtonInteractions() {
    ViewInteraction[] buttonsInteractions = new ViewInteraction[2];
    buttonsInteractions[0] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text9));
    buttonsInteractions[1] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text11));
    return buttonsInteractions;
}
 
開發者ID:philliphsu,項目名稱:NumberPadTimePicker,代碼行數:7,代碼來源:NumberPadTimePickerDialogTest.java


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