mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 14:52:13 -04:00
simplify references to ViewInteractions
This commit is contained in:
parent
87239ce67a
commit
394ca0dabe
@ -93,20 +93,11 @@ public class HelpActivityTest {
|
|||||||
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
||||||
|
|
||||||
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
|
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
|
||||||
|
onView(withText("Help")).perform(click());
|
||||||
ViewInteraction appCompatTextView = onView(
|
|
||||||
allOf(withId(R.id.title), withText("Help"),
|
|
||||||
childAtPosition(
|
|
||||||
childAtPosition(
|
|
||||||
withClassName(is("android.support.v7.view.menu.ListMenuItemView")),
|
|
||||||
0),
|
|
||||||
0),
|
|
||||||
isDisplayed()));
|
|
||||||
appCompatTextView.perform(click());
|
|
||||||
|
|
||||||
|
|
||||||
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
||||||
|
|
||||||
|
// Verify that the help Activity is opened
|
||||||
ViewInteraction textView = onView(
|
ViewInteraction textView = onView(
|
||||||
allOf(withText("Help"),
|
allOf(withText("Help"),
|
||||||
childAtPosition(
|
childAtPosition(
|
||||||
@ -118,6 +109,7 @@ public class HelpActivityTest {
|
|||||||
isDisplayed()));
|
isDisplayed()));
|
||||||
textView.check(matches(withText("Help")));
|
textView.check(matches(withText("Help")));
|
||||||
|
|
||||||
|
// Verify that the back button is displayed
|
||||||
ViewInteraction imageButton = onView(
|
ViewInteraction imageButton = onView(
|
||||||
allOf(withContentDescription("Navigate up"),
|
allOf(withContentDescription("Navigate up"),
|
||||||
childAtPosition(
|
childAtPosition(
|
||||||
@ -132,6 +124,7 @@ public class HelpActivityTest {
|
|||||||
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
||||||
|
|
||||||
|
|
||||||
|
// Verify that going back from the help screen we go to the previous screen
|
||||||
ViewInteraction appCompatImageButton = onView(
|
ViewInteraction appCompatImageButton = onView(
|
||||||
allOf(withContentDescription("Navigate up"),
|
allOf(withContentDescription("Navigate up"),
|
||||||
childAtPosition(
|
childAtPosition(
|
||||||
@ -145,7 +138,7 @@ public class HelpActivityTest {
|
|||||||
|
|
||||||
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
||||||
|
|
||||||
|
// Verify that the home activity is opened
|
||||||
ViewInteraction textView2 = onView(
|
ViewInteraction textView2 = onView(
|
||||||
allOf(withText("Wikipedia"),
|
allOf(withText("Wikipedia"),
|
||||||
childAtPosition(
|
childAtPosition(
|
||||||
@ -181,14 +174,7 @@ public class HelpActivityTest {
|
|||||||
isDisplayed()));
|
isDisplayed()));
|
||||||
appCompatTextView2.perform(click());
|
appCompatTextView2.perform(click());
|
||||||
|
|
||||||
// Added a sleep statement to match the app's execution delay.
|
BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
|
||||||
// The recommended way to handle such scenarios is to use Espresso idling resources:
|
|
||||||
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
|
|
||||||
try {
|
|
||||||
Thread.sleep(80000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
pressBack();
|
pressBack();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user