Commit f905b7c8 authored by Iulia Harasim's avatar Iulia Harasim Committed by Commit Bot

[Android] Add render tests for personalized signin promos in NTP

This CL adds render tests for personalized signin promos in NTP content
suggestions and the golden files associated to each test.

Bug: 737743
Change-Id: I32cacf8cb5e8aac1a507581e43b18e765d790ecb
Reviewed-on: https://chromium-review.googlesource.com/667147Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarNicolas Dossou-Gbété <dgn@chromium.org>
Commit-Queue: Iulia Harasim <iuliah@google.com>
Cr-Commit-Position: refs/heads/master@{#502857}
parent 360f366c
...@@ -153,7 +153,7 @@ public class SignInPromo extends OptionalLeaf implements ImpressionTracker.Liste ...@@ -153,7 +153,7 @@ public class SignInPromo extends OptionalLeaf implements ImpressionTracker.Liste
assert !mWasDismissed; assert !mWasDismissed;
if (mArePersonalizedPromosEnabled) { if (mArePersonalizedPromosEnabled) {
return new PersonalizedPromoViewHolder( return new PersonalizedPromoViewHolder(
parent, contextMenuManager, config, mProfileDataCache, mSigninPromoController); parent, config, contextMenuManager, mProfileDataCache, mSigninPromoController);
} }
return new GenericPromoViewHolder(parent, contextMenuManager, config); return new GenericPromoViewHolder(parent, contextMenuManager, config);
} }
...@@ -324,13 +324,14 @@ public class SignInPromo extends OptionalLeaf implements ImpressionTracker.Liste ...@@ -324,13 +324,14 @@ public class SignInPromo extends OptionalLeaf implements ImpressionTracker.Liste
/** /**
* View Holder for {@link SignInPromo} if the personalized promo is to be shown. * View Holder for {@link SignInPromo} if the personalized promo is to be shown.
*/ */
private static class PersonalizedPromoViewHolder extends CardViewHolder { @VisibleForTesting
public static class PersonalizedPromoViewHolder extends CardViewHolder {
private final ProfileDataCache mProfileDataCache; private final ProfileDataCache mProfileDataCache;
private final SigninPromoController mSigninPromoController; private final SigninPromoController mSigninPromoController;
public PersonalizedPromoViewHolder(SuggestionsRecyclerView parent, public PersonalizedPromoViewHolder(SuggestionsRecyclerView parent, UiConfig config,
ContextMenuManager contextMenuManager, UiConfig config, ContextMenuManager contextMenuManager, ProfileDataCache profileDataCache,
ProfileDataCache profileDataCache, SigninPromoController signinPromoController) { SigninPromoController signinPromoController) {
super(FeatureUtilities.isChromeHomeModernEnabled() super(FeatureUtilities.isChromeHomeModernEnabled()
? R.layout.personalized_signin_promo_view_modern_content_suggestions ? R.layout.personalized_signin_promo_view_modern_content_suggestions
: R.layout.personalized_signin_promo_view_ntp_content_suggestions, : R.layout.personalized_signin_promo_view_ntp_content_suggestions,
...@@ -372,6 +373,19 @@ public class SignInPromo extends OptionalLeaf implements ImpressionTracker.Liste ...@@ -372,6 +373,19 @@ public class SignInPromo extends OptionalLeaf implements ImpressionTracker.Liste
SigninPromoView view = (SigninPromoView) itemView; SigninPromoView view = (SigninPromoView) itemView;
mSigninPromoController.setupSigninPromoView(view.getContext(), view, null); mSigninPromoController.setupSigninPromoView(view.getContext(), view, null);
} }
/**
* Binds the view and sets the profile data directly. Used for testing purposes.
* @param profileData The profile data which will be used to configure the personalized
* signin promo.
*/
@VisibleForTesting
public void bindAndConfigureViewForTests(@Nullable DisplayableProfileData profileData) {
super.onBindViewHolder();
mSigninPromoController.setProfileData(profileData);
SigninPromoView view = (SigninPromoView) itemView;
mSigninPromoController.setupSigninPromoView(view.getContext(), view, null);
}
} }
/** Defines the appearance and the behaviour of a generic Sign In Promo card. */ /** Defines the appearance and the behaviour of a generic Sign In Promo card. */
......
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