From 10fa73def7af6abc9bfe447dfc6b7740644da0b4 Mon Sep 17 00:00:00 2001 From: afohrman Date: Fri, 14 Jul 2017 15:08:51 -0400 Subject: [PATCH] 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 --- .../testutils/TextInputLayoutActions.java | 32 ++----------------- .../design/widget/TextInputLayoutTest.java | 3 +- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/tests/javatests/android/support/design/testutils/TextInputLayoutActions.java b/tests/javatests/android/support/design/testutils/TextInputLayoutActions.java index 28b8c9650..fc0d77cfc 100644 --- a/tests/javatests/android/support/design/testutils/TextInputLayoutActions.java +++ b/tests/javatests/android/support/design/testutils/TextInputLayoutActions.java @@ -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 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(); } }; } diff --git a/tests/javatests/android/support/design/widget/TextInputLayoutTest.java b/tests/javatests/android/support/design/widget/TextInputLayoutTest.java index ffcafd0af..a4140c14e 100644 --- a/tests/javatests/android/support/design/widget/TextInputLayoutTest.java +++ b/tests/javatests/android/support/design/widget/TextInputLayoutTest.java @@ -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) {