类android.support.test.espresso.DataInteraction源码实例Demo

下面列出了怎么用android.support.test.espresso.DataInteraction的API类实例代码及写法,或者点击链接到github查看源代码。

/**
 * Tests the disableFingerprintLockscreen SwitchPreference.
 */
@Test
public void disableFingerprintLockscreenPreferenceTest() {
    DataInteraction linearLayout = onData(anything())
            .inAdapterView(allOf(withId(android.R.id.list),
                    childAtPosition(
                            withId(android.R.id.list_container)
                    )))
            .atPosition(0);
    linearLayout.perform(click());

    DataInteraction linearLayout2 = onData(anything())
            .inAdapterView(allOf(withId(android.R.id.list),
                    childAtPosition(
                            withId(android.R.id.list_container)
                    )))
            .atPosition(0);
    linearLayout2.perform(click());

}
 
源代码2 项目: Android   文件: GroupSetTest.java
public void qrcodeTest(){
    ViewInteraction groupNameView = onView(withId(R.id.groupset_qrcode));
    groupNameView.check(matches(isEnabled()));
    groupNameView.perform(click());

    ViewInteraction rightView = onView(allOf(withId(R.id.right_lin), isDisplayed()));
    rightView.perform(click());

    DataInteraction listView = onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(0);
    listView.perform(click());

    ViewInteraction confirmView = onView(allOf(withId(R.id.okBtn), isDisplayed()));
    confirmView.perform(click());

    ViewInteraction leftView = onView(allOf(withId(R.id.left_rela), isDisplayed()));
    leftView.perform(click());
}
 
public static void verifyLocaleSettings(Context context)
{
    // verify the mode selector
    DataInteraction modePref = onData(allOf( is(instanceOf(Preference.class)), withKey("app_locale_mode")))
            .inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))));
    modePref.check(assertEnabled);

    AppSettings.LocaleMode mode = AppSettings.loadLocaleModePref(context);
    DataInteraction modePref_text = modePref.onChildView(allOf(withClassName(is(TextView.class.getName())), withText(mode.getDisplayString())));
    modePref_text.check(assertShown);

    // verify the language selector
    DataInteraction langPref = onData(allOf(is(instanceOf(Preference.class)), withKey("app_locale")))
            .inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))));
    langPref.check(assertShown);

    if (mode == AppSettings.LocaleMode.SYSTEM_LOCALE)
        langPref.check(assertDisabled);       // language disabled for system mode
    else langPref.check(assertEnabled);

    String lang = getLocaleDisplayString(context, AppSettings.loadLocalePref(context));
    DataInteraction langPref_text = langPref.onChildView(allOf(withClassName(is(TextView.class.getName())), withText(lang)));
    langPref_text.check(assertShown);
}
 
源代码4 项目: Android   文件: GroupSetTest.java
public void otherTest() {
    ViewInteraction clearView = onView(withId(R.id.clear));
    clearView.perform(click());
    ViewInteraction cancelView = onView(withId(R.id.tv_popup_cancel)).check(matches(isDisplayed()));
    cancelView.perform(click());
    clearView.perform(click());
    DataInteraction confirmView = onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(0);
    confirmView.perform(click());

    ViewInteraction exitView = onView(withId(R.id.delete));
    exitView.perform(click());
    ViewInteraction okView = onView(allOf(withId(R.id.okBtn), isDisplayed()));
    okView.perform(click());
}
 
源代码5 项目: Android   文件: SingleSetTest.java
public void clearTest() {
    ViewInteraction clearView = onView(withId(R.id.clear));
    clearView.perform(click());
    ViewInteraction cancelView = onView(withId(R.id.tv_popup_cancel)).check(matches(isDisplayed()));
    cancelView.perform(click());

    clearView.perform(click());
    DataInteraction confirmView = onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(0);
    confirmView.perform(click());
}
 
public static void verifyGeneralSettings_dataSource(Context context)
{
    DataInteraction dataSourcePref = onData(allOf( is(instanceOf(Preference.class)), withKey("appwidget_0_general_calculator")) ).inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))));
    dataSourcePref.check(assertEnabled);

    SuntimesCalculatorDescriptor dataSource = WidgetSettings.loadCalculatorModePref(context, 0);
    DataInteraction dataSourcePref_text = dataSourcePref.onChildView(allOf(withClassName(is(TextView.class.getName())), withText(dataSource.getName())));
    dataSourcePref_text.check(assertShown);
}
 
public static void verifyPlacesSettings_gpsTimeLimit(Context context)
{
    DataInteraction gpsTimePref = onData(
            allOf( is(instanceOf(Preference.class)), withKey("getFix_maxElapsed")) )
            .inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))));
    gpsTimePref.check(assertEnabled);
    // TODO: verify correct setting
}
 
public static void verifyPlacesSettings_gpsMaxAge(Context context)
{
    DataInteraction gpsAgePref = onData(
            allOf( is(instanceOf(Preference.class)), withKey("getFix_maxAge")) )
            .inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))) );
    gpsAgePref.check(assertEnabled);
    // TODO: verify correct setting
}
 
public static void verifyUISettings_lightmap(Context context)
{
    DataInteraction lightmapPref = onData(allOf(is(instanceOf(Preference.class)), withKey("app_ui_showlightmap"))).inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))));
    lightmapPref.check(assertEnabled);

    DataInteraction lightmapPref_checkBox = lightmapPref.onChildView(withClassName(is(CheckBox.class.getName())));
    if (AppSettings.loadShowLightmapPref(context))
        lightmapPref_checkBox.check(assertChecked);
    else lightmapPref_checkBox.check(assertNotChecked);
}
 
public static void verifyUISettings_uiWarnings(Context context)
{
    DataInteraction warningPref = onData(allOf( is(instanceOf(Preference.class)), withKey("app_ui_showwarnings"))).inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))) );
    warningPref.check(assertEnabled);

    DataInteraction warningPref_checkBox = warningPref.onChildView(withClassName(is(CheckBox.class.getName())));
    if (AppSettings.loadShowWarningsPref(context))
        warningPref_checkBox.check(assertChecked);
    else warningPref_checkBox.check(assertNotChecked);
}
 
public static void verifyUISettings_noteTap(Context context)
{
    DataInteraction notetapPref = onData(allOf( is(instanceOf(Preference.class)), withKey("app_ui_notetapaction"))).inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))));
    notetapPref.check(assertEnabled);

    //AppSettings.ClockTapAction action = AppSettings.loadNoteTapActionPref(context);
    //DataInteraction notetapPref_text = notetapPref.onChildView(allOf(withClassName(is(TextView.class.getName())), withText(containsString(action.getDisplayString()))));
    //notetapPref_text.check(assertShown);
    // TODO
}
 
public static void verifyUISettings_dateTap(Context context)
{
    DataInteraction datetapPref = onData(allOf( is(instanceOf(Preference.class)), withKey("app_ui_datetapaction"))).inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))) );
    datetapPref.check(assertEnabled);

    //AppSettings.DateTapAction action = AppSettings.loadDateTapActionPref(context);
    //DataInteraction datetapPref_text = datetapPref.onChildView(allOf(withClassName(is(TextView.class.getName())), withText(containsString(action.getDisplayString()))));
    //datetapPref_text.check(assertShown);
    // TODO
}
 
public static void verifyUISettings_clockTap(Context context)
{
    DataInteraction clocktapPref = onData(allOf( is(instanceOf(Preference.class)), withKey("app_ui_clocktapaction"))).inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))) );
    clocktapPref.check(assertEnabled);

    //AppSettings.ClockTapAction action = AppSettings.loadClockTapActionPref(context);
    //DataInteraction clocktapPref_text = clocktapPref.onChildView(allOf(withClassName(is(TextView.class.getName())), withText(containsString(action.getDisplayString()))));
    //clocktapPref_text.check(assertShown);
    // TODO
}
 
public static void verifyUISettings_timeFormatMode(Context context)
{
    DataInteraction formatPref = onData(allOf( is(instanceOf(Preference.class)), withKey("appwidget_0_appearance_timeformatmode"))).inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))));
    formatPref.check(assertEnabled);

    WidgetSettings.TimeFormatMode mode = WidgetSettings.loadTimeFormatModePref(context, 0);
    String modeSummary = String.format(SuntimesSettingsActivity.timeFormatPrefSummary(mode, context), mode.getDisplayString());
    DataInteraction formatPref_text = formatPref.onChildView(allOf(withClassName(is(TextView.class.getName())), withText(modeSummary)));
    formatPref_text.check(assertShown);
}
 
public static void verifyUISettings_theme(Activity activity)
{
    DataInteraction themePref = onData(allOf( is(instanceOf(Preference.class)), withKey("app_appearance_theme"))).inAdapterView(allOf(hasFocus(), is(instanceOf(ListView.class))));
    themePref.check(assertEnabled);

    String themeName = AppSettings.loadThemePref(activity);
    String themeDisplay = getThemeDisplayString(activity, themeName);
    DataInteraction themePref_text = themePref.onChildView(allOf(withClassName(is(TextView.class.getName())), withText(themeDisplay)));
    themePref_text.check(assertShown);
}
 
源代码16 项目: AndroidProjects   文件: LongListActivityTest.java
/**
 * Uses {@link Espresso#onData(org.hamcrest.Matcher)} to get a reference to a specific row.
 * <p>
 * Note: A custom matcher can be used to match the content and have more readable code.
 * See the Custom Matcher Sample.
 * </p>
 *
 * @param str the content of the field
 * @return a {@link DataInteraction} referencing the row
 */
private static DataInteraction onRow(String str) {
    return onData(hasEntry(equalTo(LongListActivity.ROW_TEXT), is(str)));
}
 
源代码17 项目: testing-cin   文件: LongListActivityTest.java
/**
 * Uses {@link Espresso#onData(org.hamcrest.Matcher)} to get a reference to a specific row.
 * <p>
 * Note: A custom matcher can be used to match the content and have more readable code.
 * See the Custom Matcher Sample.
 * </p>
 *
 * @param str the content of the field
 * @return a {@link DataInteraction} referencing the row
 */
private static DataInteraction onRow(String str) {
    return onData(hasEntry(equalTo(LongListActivity.ROW_TEXT), is(str)));
}
 
 类所在包
 类方法
 同包方法