android.support.test.espresso.DataInteraction Java Examples

The following examples show how to use android.support.test.espresso.DataInteraction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroupSetTest.java    From Android with MIT License 6 votes vote down vote up
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());
}
 
Example #2
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: ControlYourDeviceActivityTest.java    From AdminControl with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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());

}
 
Example #4
Source File: GroupSetTest.java    From Android with MIT License 5 votes vote down vote up
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());
}
 
Example #5
Source File: SingleSetTest.java    From Android with MIT License 5 votes vote down vote up
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());
}
 
Example #6
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #7
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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
}
 
Example #8
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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
}
 
Example #9
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #10
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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
}
 
Example #12
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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
}
 
Example #13
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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
}
 
Example #14
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #15
Source File: SuntimesSettingsActivityTest.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #16
Source File: LongListActivityTest.java    From AndroidProjects with MIT License 2 votes vote down vote up
/**
 * 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)));
}
 
Example #17
Source File: LongListActivityTest.java    From testing-cin with MIT License 2 votes vote down vote up
/**
 * 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)));
}