Commit 5a7f5fe4 authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Commit Bot

[Android] Add render test for SyncPromo in NewTabPageTest

This cl adds a test for checking SyncPromo in NewTabPageTest when
MOBILE_IDENTITY_CONSISTENCY flag is on.
Signin promo was not being updated when signed in state had changed.
This cl also fixes that issue.

Bug: 1100895
Change-Id: I760f563d4ae54813e3cf06d7cf88d4c601be91fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2513218
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826725}
parent 208a6e6e
...@@ -239,6 +239,8 @@ public abstract class SignInPromo extends OptionalLeaf { ...@@ -239,6 +239,8 @@ public abstract class SignInPromo extends OptionalLeaf {
// implementing this we can show the promo if the user did not sign in during the FRE. // implementing this we can show the promo if the user did not sign in during the FRE.
mCanSignIn = mSigninManager.isSignInAllowed(); mCanSignIn = mSigninManager.isSignInAllowed();
updateVisibility(); updateVisibility();
// Update the promo state between sign-in promo and sync promo if required.
notifyDataChanged();
} }
// SignInStateObserver implementation. // SignInStateObserver implementation.
...@@ -246,12 +248,16 @@ public abstract class SignInPromo extends OptionalLeaf { ...@@ -246,12 +248,16 @@ public abstract class SignInPromo extends OptionalLeaf {
public void onSignedIn() { public void onSignedIn() {
mCanSignIn = false; mCanSignIn = false;
updateVisibility(); updateVisibility();
// Update the promo state between sign-in promo and sync promo if required.
notifyDataChanged();
} }
@Override @Override
public void onSignedOut() { public void onSignedOut() {
mCanSignIn = mSigninManager.isSignInAllowed(); mCanSignIn = mSigninManager.isSignInAllowed();
updateVisibility(); updateVisibility();
// Update the promo state between sign-in promo and sync promo if required.
notifyDataChanged();
} }
// AccountsChangeObserver implementation. // AccountsChangeObserver implementation.
......
...@@ -63,10 +63,12 @@ import org.chromium.chrome.test.util.ChromeTabUtils; ...@@ -63,10 +63,12 @@ import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.NewTabPageTestUtils; import org.chromium.chrome.test.util.NewTabPageTestUtils;
import org.chromium.chrome.test.util.OmniboxTestUtils; import org.chromium.chrome.test.util.OmniboxTestUtils;
import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.chrome.test.util.browser.suggestions.SuggestionsDependenciesRule; import org.chromium.chrome.test.util.browser.suggestions.SuggestionsDependenciesRule;
import org.chromium.chrome.test.util.browser.suggestions.mostvisited.FakeMostVisitedSites; import org.chromium.chrome.test.util.browser.suggestions.mostvisited.FakeMostVisitedSites;
import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator; import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator;
import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.components.signin.test.util.FakeProfileDataSource;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.test.util.KeyUtils; import org.chromium.content_public.browser.test.util.KeyUtils;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
...@@ -107,6 +109,9 @@ public class NewTabPageTest { ...@@ -107,6 +109,9 @@ public class NewTabPageTest {
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule(); public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
@Rule @Rule
public SuggestionsDependenciesRule mSuggestionsDeps = new SuggestionsDependenciesRule(); public SuggestionsDependenciesRule mSuggestionsDeps = new SuggestionsDependenciesRule();
@Rule
public AccountManagerTestRule mAccountManagerTestRule =
new AccountManagerTestRule(new FakeProfileDataSource());
@Rule @Rule
public ChromeRenderTestRule mRenderTestRule = ChromeRenderTestRule.Builder.withPublicCorpus() public ChromeRenderTestRule mRenderTestRule = ChromeRenderTestRule.Builder.withPublicCorpus()
...@@ -191,6 +196,19 @@ public class NewTabPageTest { ...@@ -191,6 +196,19 @@ public class NewTabPageTest {
mNtp.getCoordinatorForTesting().getSignInPromoViewForTesting(), "sign_in_promo"); mNtp.getCoordinatorForTesting().getSignInPromoViewForTesting(), "sign_in_promo");
} }
@Test
@SmallTest
@Feature({"NewTabPage", "FeedNewTabPage", "RenderTest"})
@Features.EnableFeatures(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
public void testRender_SyncPromo() throws Exception {
mAccountManagerTestRule.addTestAccountThenSignin();
// Scroll to the sign in promo in case it is not visible.
onView(instanceOf(RecyclerView.class))
.perform(RecyclerViewActions.scrollToPosition(SIGNIN_PROMO_POSITION));
mRenderTestRule.render(
mNtp.getCoordinatorForTesting().getSignInPromoViewForTesting(), "sync_promo");
}
@Test @Test
@MediumTest @MediumTest
@Feature({"NewTabPage", "FeedNewTabPage", "RenderTest"}) @Feature({"NewTabPage", "FeedNewTabPage", "RenderTest"})
......
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