use of android.support.test.espresso.ViewInteraction in project Space-Station-Tracker by Kiarasht.
the class AboutActivityTest method aboutActivityTest.
@Test
public void aboutActivityTest() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
onView(allOf(withId(R.id.action_bar_right_bmb), isDisplayed())).perform(click());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
onView(allOf(withId(R.id.button), withChild(withText("Help")), isDisplayed())).perform(click());
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ViewInteraction textView = onView(allOf(withText("ISS Tracker"), childAtPosition(childAtPosition(IsInstanceOf.<View>instanceOf(android.widget.ScrollView.class), 0), 0), isDisplayed()));
textView.check(matches(withText("ISS Tracker")));
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ViewInteraction textView2 = onView(allOf(withText("Open source licenses"), childAtPosition(childAtPosition(IsInstanceOf.<View>instanceOf(android.widget.ScrollView.class), 0), 10), isDisplayed()));
textView2.check(matches(withText("Open source licenses")));
ViewInteraction textView3 = onView(allOf(withText("Versions"), childAtPosition(childAtPosition(IsInstanceOf.<View>instanceOf(android.widget.ScrollView.class), 0), 14), isDisplayed()));
textView3.check(matches(withText("Versions")));
}
use of android.support.test.espresso.ViewInteraction in project ChipsLayoutManager by BelooS.
the class FewChipsColumnTest method deleteItemInTheFirstLine_ItemHasMaximumWidth_SameStartPadding.
@Test
public void deleteItemInTheFirstLine_ItemHasMaximumWidth_SameStartPadding() throws Exception {
//arrange
{
//just adapt input items list to required start values
items.remove(1);
items.remove(9);
ChipsEntity longItem = items.remove(8);
items.add(1, longItem);
}
activity.runOnUiThread(() -> activity.initialize());
ViewInteraction recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
//just adapt input items list to required start values
InstrumentalUtil.waitForIdle();
View second = layoutManager.getChildAt(1);
double expectedX = second.getX();
//act
recyclerView.perform(actionDelegate(((uiController, view) -> items.remove(1))), notifyItemRemovedAction(1));
InstrumentalUtil.waitForIdle();
second = layoutManager.getChildAt(5);
double resultX = second.getX();
//assert
assertNotEquals(0, expectedX, 0.01);
assertNotEquals(0, resultX, 0.01);
assertEquals(resultX, expectedX, 0.01);
}
use of android.support.test.espresso.ViewInteraction in project ChipsLayoutManager by BelooS.
the class FewChipsColumnTest method wrapContent_HeightIsWrapContent_DeletedLastItemInLastRowCauseHeightToDecrease.
@Test
public void wrapContent_HeightIsWrapContent_DeletedLastItemInLastRowCauseHeightToDecrease() throws Exception {
//arrange
activity.runOnUiThread(() -> activity.initialize());
final RecyclerView[] rvTest = new RecyclerView[1];
ViewInteraction recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
ViewAction viewAction = actionDelegate(((uiController, view) -> {
rvTest[0] = view;
view.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
view.requestLayout();
}));
recyclerView.perform(viewAction);
int startWidth = rvTest[0].getHeight();
//act
recyclerView.perform(actionDelegate(((uiController, view) -> items.remove(9))), notifyItemRemovedAction(9));
InstrumentalUtil.waitForIdle();
//assert
int endWidth = rvTest[0].getWidth();
System.out.println(String.format(Locale.getDefault(), "start height = %d, end height = %d", startWidth, endWidth));
assertTrue(endWidth < startWidth);
}
use of android.support.test.espresso.ViewInteraction in project ChipsLayoutManager by BelooS.
the class FewChipsRowTest method wrapContent_HeightIsWrapContent_DeletedLastItemInLastRowCauseHeightToDecrease.
@Test
public void wrapContent_HeightIsWrapContent_DeletedLastItemInLastRowCauseHeightToDecrease() throws Exception {
//arrange
activity.runOnUiThread(() -> activity.initialize());
final RecyclerView[] rvTest = new RecyclerView[1];
ViewInteraction recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
ViewAction viewAction = actionDelegate((uiController, view) -> {
rvTest[0] = view;
view.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
view.requestLayout();
});
recyclerView.perform(viewAction);
int startHeight = rvTest[0].getHeight();
//act
recyclerView.perform(actionDelegate(((uiController, view) -> items.remove(9))), notifyItemRemovedAction(9));
//assert
int endHeight = rvTest[0].getHeight();
System.out.println(String.format(Locale.getDefault(), "start height = %d, end height = %d", startHeight, endHeight));
assertTrue(endHeight < startHeight);
}
use of android.support.test.espresso.ViewInteraction in project dobby-android by InceptAi.
the class WifiExpertUITests method checkIdleState.
private void checkIdleState(boolean initialAppLaunch) {
captureScreenshot("idle_state");
checkSlowInternetCheckWifiAndRunSpeedTestButtons();
if (!initialAppLaunch) {
checkDetailsButton(3);
}
if (initialAppLaunch) {
ViewInteraction textView = onView(allOf(withId(R.id.dobbyTextTv), withText(containsString("run tests")), childAtPosition(allOf(withId(R.id.dobbyChatLayout), childAtPosition(withId(R.id.chatRv), 0)), 1), isDisplayed()));
textView.check(matches(withText(containsString("run tests"))));
}
}
Aggregations