Search in sources :

Example 16 with ViewInteraction

use of androidx.test.espresso.ViewInteraction in project BetterBatteryStats by asksven.

the class ClickThroughTest method clickThroughTest.

@Test
public void clickThroughTest() {
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
    ViewInteraction appCompatTextView = onView(allOf(withId(R.id.title), withText("Set Custom Ref."), isDisplayed()));
    appCompatTextView.perform(click());
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
    ViewInteraction appCompatTextView2 = onView(allOf(withId(R.id.title), withText("Graphs"), isDisplayed()));
    appCompatTextView2.perform(click());
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    ViewInteraction appCompatImageButton = onView(allOf(withContentDescription("Navigate up"), withParent(withId(R.id.toolbar)), isDisplayed()));
    appCompatImageButton.perform(click());
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
    ViewInteraction appCompatTextView3 = onView(allOf(withId(R.id.title), withText("Raw Stats"), isDisplayed()));
    appCompatTextView3.perform(click());
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    ViewInteraction appCompatImageButton2 = onView(allOf(withContentDescription("Navigate up"), withParent(withId(R.id.toolbar)), isDisplayed()));
    appCompatImageButton2.perform(click());
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
    ViewInteraction appCompatTextView4 = onView(allOf(withId(R.id.title), withText("Settings"), isDisplayed()));
    appCompatTextView4.perform(click());
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    ViewInteraction appCompatImageButton3 = onView(allOf(withContentDescription("Navigate up"), withParent(withId(R.id.toolbar)), isDisplayed()));
    appCompatImageButton3.perform(click());
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
    ViewInteraction appCompatTextView5 = onView(allOf(withId(R.id.title), withText("About"), isDisplayed()));
    appCompatTextView5.perform(click());
    // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    ViewInteraction appCompatImageButton4 = onView(allOf(withContentDescription("Navigate up"), withParent(withId(R.id.toolbar)), isDisplayed()));
    appCompatImageButton4.perform(click());
}
Also used : ViewInteraction(androidx.test.espresso.ViewInteraction) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 17 with ViewInteraction

use of androidx.test.espresso.ViewInteraction in project BetterBatteryStats by asksven.

the class ShareActivityTestAll method shareActivityTestAll.

@Test
public void shareActivityTestAll() {
    ViewInteraction actionMenuItemView = onView(allOf(withId(R.id.share), withContentDescription("Share"), isDisplayed()));
    actionMenuItemView.perform(click());
    ViewInteraction appCompatCheckedTextView = onView(allOf(withId(android.R.id.text1), withText("logcat"), childAtPosition(allOf(withClassName(is("com.android.internal.app.AlertController$RecycleListView")), withParent(withClassName(is("android.widget.LinearLayout")))), 1), isDisplayed()));
    appCompatCheckedTextView.perform(click());
    ViewInteraction appCompatCheckedTextView2 = onView(allOf(withId(android.R.id.text1), withText("dmesg"), childAtPosition(allOf(withClassName(is("com.android.internal.app.AlertController$RecycleListView")), withParent(withClassName(is("android.widget.LinearLayout")))), 2), isDisplayed()));
    appCompatCheckedTextView2.perform(click());
    ViewInteraction editText = onView(allOf(withClassName(is("android.widget.EditText")), isDisplayed()));
    editText.perform(click());
    ViewInteraction appCompatButton = onView(allOf(withId(android.R.id.button3), withText("Save"), isDisplayed()));
    appCompatButton.perform(click());
}
Also used : ViewInteraction(androidx.test.espresso.ViewInteraction) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Aggregations

ViewInteraction (androidx.test.espresso.ViewInteraction)17 Test (org.junit.Test)16 LargeTest (androidx.test.filters.LargeTest)9 Intent (android.content.Intent)1 CheckBox (android.widget.CheckBox)1 NoMatchingViewException (androidx.test.espresso.NoMatchingViewException)1 UiObject (androidx.test.uiautomator.UiObject)1 UiSelector (androidx.test.uiautomator.UiSelector)1 ViewVisibilityIdlingResource (com.github.pockethub.android.tests.ViewVisibilityIdlingResource)1