Remove unnecessary looper calls in TextInputLayout's ViewActions.

Espresso does not need the uiController.loopMainThreadUntilIdle() calls, so I removed them. Verified that removing these calls didn't add flakiness by running them with --runs_per_test=100.

PiperOrigin-RevId: 161989235
This commit is contained in:
afohrman 2017-07-14 15:08:51 -04:00 committed by Miguel Yanez Barreto
parent 680e3c3a25
commit 10fa73def7
2 changed files with 3 additions and 32 deletions

View File

@ -41,17 +41,13 @@ public class TextInputLayoutActions {
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setErrorEnabled(enabled);
uiController.loopMainThreadUntilIdle();
}
};
}
public static ViewAction setError(final CharSequence error) {
public static ViewAction setError(final CharSequence errorText) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
@ -65,12 +61,8 @@ public class TextInputLayoutActions {
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setError(error);
uiController.loopMainThreadUntilIdle();
layout.setError(errorText);
}
};
}
@ -89,12 +81,8 @@ public class TextInputLayoutActions {
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setErrorTextAppearance(resId);
uiController.loopMainThreadUntilIdle();
}
};
}
@ -113,12 +101,8 @@ public class TextInputLayoutActions {
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setTypeface(typeface);
uiController.loopMainThreadUntilIdle();
}
};
}
@ -137,12 +121,8 @@ public class TextInputLayoutActions {
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setPasswordVisibilityToggleEnabled(enabled);
uiController.loopMainThreadUntilIdle();
}
};
}
@ -161,12 +141,8 @@ public class TextInputLayoutActions {
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setCounterEnabled(enabled);
uiController.loopMainThreadUntilIdle();
}
};
}
@ -185,12 +161,8 @@ public class TextInputLayoutActions {
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setCounterMaxLength(maxLength);
uiController.loopMainThreadUntilIdle();
}
};
}

View File

@ -459,8 +459,7 @@ public class TextInputLayoutTest {
@Test
public void testTextSetViaAttributeCollapsedHint() {
onView(withId(R.id.textinput_with_text))
.check(isHintExpanded(false));
onView(withId(R.id.textinput_with_text)).check(isHintExpanded(false));
}
private static ViewAssertion isHintExpanded(final boolean expanded) {