Commit bc42696a authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][WebSignin][Test] Clean up criteria with ambiguous views

This CL cleans up criteria in account picker bottom sheet tests that
use ambiguous views in the view state refactoring later.


Bug: 1138824
Change-Id: Ibf8d3dcf40c5d387d2befbd90b89a114e09fbabb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502429Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821735}
parent 9da062f6
...@@ -303,8 +303,8 @@ public class AccountPickerBottomSheetRenderTest { ...@@ -303,8 +303,8 @@ public class AccountPickerBottomSheetRenderTest {
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
accountListView.findViewHolderForAdapterPosition(3).itemView.performClick(); accountListView.findViewHolderForAdapterPosition(3).itemView.performClick();
}); });
CriteriaHelper.pollUiThread(bottomSheetView.findViewById( CriteriaHelper.pollUiThread(
R.id.incognito_interstitial_bottom_sheet_view)::isShown); bottomSheetView.findViewById(R.id.incognito_interstitial_learn_more)::isShown);
} }
private void clickContinueButtonAndWaitForErrorView() { private void clickContinueButtonAndWaitForErrorView() {
...@@ -313,9 +313,7 @@ public class AccountPickerBottomSheetRenderTest { ...@@ -313,9 +313,7 @@ public class AccountPickerBottomSheetRenderTest {
bottomSheetView.findViewById(R.id.account_picker_continue_as_button).performClick(); bottomSheetView.findViewById(R.id.account_picker_continue_as_button).performClick();
}); });
CriteriaHelper.pollUiThread(() -> { CriteriaHelper.pollUiThread(() -> {
return !bottomSheetView.findViewById(R.id.account_picker_selected_account).isShown() return !bottomSheetView.findViewById(R.id.account_picker_selected_account).isShown();
&& bottomSheetView.findViewById(R.id.account_picker_bottom_sheet_subtitle)
.isShown();
}); });
} }
......
...@@ -44,7 +44,6 @@ import org.mockito.Captor; ...@@ -44,7 +44,6 @@ import org.mockito.Captor;
import org.mockito.Mock; import org.mockito.Mock;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Batch; import org.chromium.base.test.util.Batch;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.MetricsUtils; import org.chromium.base.test.util.MetricsUtils;
...@@ -363,7 +362,7 @@ public class AccountPickerBottomSheetTest { ...@@ -363,7 +362,7 @@ public class AccountPickerBottomSheetTest {
buildAndShowExpandedBottomSheet(); buildAndShowExpandedBottomSheet();
onView(withText(PROFILE_DATA2.getAccountName())).perform(click()); onView(withText(PROFILE_DATA2.getAccountName())).perform(click());
CriteriaHelper.pollUiThread(mCoordinator.getBottomSheetViewForTesting().findViewById( CriteriaHelper.pollUiThread(mCoordinator.getBottomSheetViewForTesting().findViewById(
R.id.account_picker_continue_as_button)::isShown); R.id.account_picker_selected_account)::isShown);
clickContinueButtonAndCheckSignInInProgressSheet(); clickContinueButtonAndCheckSignInInProgressSheet();
Assert.assertEquals(1, accountConsistencyHistogram.getDelta()); Assert.assertEquals(1, accountConsistencyHistogram.getDelta());
} }
...@@ -569,11 +568,7 @@ public class AccountPickerBottomSheetTest { ...@@ -569,11 +568,7 @@ public class AccountPickerBottomSheetTest {
} }
private void checkIncognitoInterstitialSheet() { private void checkIncognitoInterstitialSheet() {
onView(withId(R.id.account_picker_bottom_sheet_logo)).check(matches(isDisplayed())); onView(withText(R.string.incognito_interstitial_title)).check(matches(isDisplayed()));
onView(withId(R.id.account_picker_bottom_sheet_title))
.check(matches(isDisplayed()))
.check(matches(withText(R.string.incognito_interstitial_title)));
onView(withId(R.id.incognito_interstitial_bottom_sheet_view)).check(matches(isDisplayed()));
onView(withId(R.id.incognito_interstitial_message)).check(matches(isDisplayed())); onView(withId(R.id.incognito_interstitial_message)).check(matches(isDisplayed()));
onView(withId(R.id.incognito_interstitial_learn_more)).check(matches(isDisplayed())); onView(withId(R.id.incognito_interstitial_learn_more)).check(matches(isDisplayed()));
onView(withId(R.id.incognito_interstitial_continue_button)).check(matches(isDisplayed())); onView(withId(R.id.incognito_interstitial_continue_button)).check(matches(isDisplayed()));
...@@ -592,29 +587,26 @@ public class AccountPickerBottomSheetTest { ...@@ -592,29 +587,26 @@ public class AccountPickerBottomSheetTest {
bottomSheetView.findViewById(R.id.account_picker_continue_as_button).performClick(); bottomSheetView.findViewById(R.id.account_picker_continue_as_button).performClick();
}); });
CriteriaHelper.pollUiThread(() -> { CriteriaHelper.pollUiThread(() -> {
return !bottomSheetView.findViewById(R.id.account_picker_selected_account).isShown() return !bottomSheetView.findViewById(R.id.account_picker_selected_account).isShown();
&& bottomSheetView.findViewById(R.id.account_picker_bottom_sheet_subtitle)
.isShown();
}); });
} }
private void clickContinueButtonAndCheckSignInInProgressSheet() { private void clickContinueButtonAndCheckSignInInProgressSheet() {
View bottomSheetView = mCoordinator.getBottomSheetViewForTesting(); View bottomSheetView = mCoordinator.getBottomSheetViewForTesting();
ThreadUtils.runOnUiThread( TestThreadUtils.runOnUiThreadBlocking(() -> {
bottomSheetView.findViewById(R.id.account_picker_continue_as_button)::performClick); bottomSheetView.findViewById(R.id.account_picker_continue_as_button).performClick();
});
CriteriaHelper.pollUiThread(() -> { CriteriaHelper.pollUiThread(() -> {
return !bottomSheetView.findViewById(R.id.account_picker_continue_as_button).isShown(); return bottomSheetView.findViewById(R.id.account_picker_signin_spinner_view).isShown();
}); });
// TODO(https://crbug.com/1116348): Check AccountPickerDelegate.signIn() is called // TODO(https://crbug.com/1116348): Check AccountPickerDelegate.signIn() is called
// after solving AsyncTask wait problem in espresso // after solving AsyncTask wait problem in espresso
Assert.assertTrue(
bottomSheetView.findViewById(R.id.account_picker_signin_spinner_view).isShown());
// Currently the ProgressBar animation cannot be disabled on android-marshmallow-arm64-rel // Currently the ProgressBar animation cannot be disabled on android-marshmallow-arm64-rel
// bot with DisableAnimationsTestRule, we hide the ProgressBar manually here to enable // bot with DisableAnimationsTestRule, we hide the ProgressBar manually here to enable
// checks of other elements on the screen. // checks of other elements on the screen.
// TODO(https://crbug.com/1115067): Delete this line once DisableAnimationsTestRule is // TODO(https://crbug.com/1115067): Delete this line once DisableAnimationsTestRule is
// fixed. // fixed.
ThreadUtils.runOnUiThread(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
bottomSheetView.findViewById(R.id.account_picker_signin_spinner_view) bottomSheetView.findViewById(R.id.account_picker_signin_spinner_view)
.setVisibility(View.GONE); .setVisibility(View.GONE);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment