Commit 91feaec9 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

Enabling sign-in promo view earlgrey tests

Bug: 661794
Change-Id: I9e9844e73583288581e9700228708edc39dfd580
Reviewed-on: https://chromium-review.googlesource.com/561147Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarEric Noyau <noyau@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491761}
parent aa2cc77c
...@@ -188,6 +188,7 @@ source_set("eg_tests") { ...@@ -188,6 +188,7 @@ source_set("eg_tests") {
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/signin", "//ios/chrome/browser/signin",
"//ios/chrome/browser/ui", "//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/authentication:authentication_ui",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/ntp:ntp_controller", "//ios/chrome/browser/ui/ntp:ntp_controller",
"//ios/chrome/browser/ui/settings", "//ios/chrome/browser/ui/settings",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_manager.h"
#include "ios/chrome/browser/experimental_flags.h" #include "ios/chrome/browser/experimental_flags.h"
#include "ios/chrome/browser/signin/signin_manager_factory.h" #include "ios/chrome/browser/signin/signin_manager_factory.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view.h"
#import "ios/chrome/browser/ui/commands/open_url_command.h" #import "ios/chrome/browser/ui/commands/open_url_command.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
#import "ios/chrome/browser/ui/settings/accounts_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/accounts_collection_view_controller.h"
...@@ -91,7 +92,7 @@ void TapButtonWithLabelId(int message_id) { ...@@ -91,7 +92,7 @@ void TapButtonWithLabelId(int message_id) {
// User must not be signed in. // User must not be signed in.
void OpenSignInFromSettings() { void OpenSignInFromSettings() {
[ChromeEarlGreyUI openSettingsMenu]; [ChromeEarlGreyUI openSettingsMenu];
TapViewWithAccessibilityId(kSettingsSignInCellId); TapViewWithAccessibilityId(kSigninPromoSecondaryButtonId);
} }
// Wait until |matcher| is accessible (not nil) // Wait until |matcher| is accessible (not nil)
...@@ -332,7 +333,8 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) { ...@@ -332,7 +333,8 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) {
TapButtonWithLabelId(IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE); TapButtonWithLabelId(IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE);
// Check that the settings home screen is shown. // Check that the settings home screen is shown.
WaitForMatcher(grey_accessibilityID(kSettingsSignInCellId)); WaitForMatcher(grey_allOf(grey_accessibilityID(kSigninPromoSecondaryButtonId),
grey_sufficientlyVisible(), nil));
[[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -382,7 +384,8 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) { ...@@ -382,7 +384,8 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) {
TapButtonWithLabelId(IDS_IOS_MANAGED_DISCONNECT_DIALOG_ACCEPT); TapButtonWithLabelId(IDS_IOS_MANAGED_DISCONNECT_DIALOG_ACCEPT);
// Check that the settings home screen is shown. // Check that the settings home screen is shown.
WaitForMatcher(grey_accessibilityID(kSettingsSignInCellId)); WaitForMatcher(grey_allOf(grey_accessibilityID(kSigninPromoSecondaryButtonId),
grey_sufficientlyVisible(), nil));
[[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -533,8 +536,9 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) { ...@@ -533,8 +536,9 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) {
AssertAuthenticatedIdentityInActiveProfile(nil); AssertAuthenticatedIdentityInActiveProfile(nil);
// Start sign-in with |identity1|. // Start sign-in with |identity1|.
WaitForMatcher(grey_accessibilityID(kSettingsSignInCellId)); WaitForMatcher(grey_allOf(grey_accessibilityID(kSigninPromoSecondaryButtonId),
TapViewWithAccessibilityId(kSettingsSignInCellId); grey_sufficientlyVisible(), nil));
TapViewWithAccessibilityId(kSigninPromoSecondaryButtonId);
TapButtonWithAccessibilityLabel(identity1.userEmail); TapButtonWithAccessibilityLabel(identity1.userEmail);
TapButtonWithLabelId(IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SIGNIN_BUTTON); TapButtonWithLabelId(IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SIGNIN_BUTTON);
...@@ -591,7 +595,7 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) { ...@@ -591,7 +595,7 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) {
[[EarlGrey selectElementWithMatcher:all_bookmarks_matcher] [[EarlGrey selectElementWithMatcher:all_bookmarks_matcher]
performAction:grey_tap()]; performAction:grey_tap()];
TapButtonWithLabelId(IDS_IOS_BOOKMARK_PROMO_SIGN_IN_BUTTON); TapViewWithAccessibilityId(kSigninPromoSecondaryButtonId);
// Assert sign-in screen was shown. // Assert sign-in screen was shown.
id<GREYMatcher> signin_matcher = id<GREYMatcher> signin_matcher =
...@@ -620,7 +624,7 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) { ...@@ -620,7 +624,7 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) {
} }
[[EarlGrey selectElementWithMatcher:all_bookmarks_matcher] [[EarlGrey selectElementWithMatcher:all_bookmarks_matcher]
performAction:grey_tap()]; performAction:grey_tap()];
TapButtonWithLabelId(IDS_IOS_BOOKMARK_PROMO_SIGN_IN_BUTTON); TapViewWithAccessibilityId(kSigninPromoSecondaryButtonId);
[[EarlGrey selectElementWithMatcher:signin_matcher] [[EarlGrey selectElementWithMatcher:signin_matcher]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
......
...@@ -20,6 +20,11 @@ typedef NS_ENUM(NSInteger, SigninPromoViewMode) { ...@@ -20,6 +20,11 @@ typedef NS_ENUM(NSInteger, SigninPromoViewMode) {
SigninPromoViewModeWarmState, SigninPromoViewModeWarmState,
}; };
extern NSString* const kSigninPromoViewId;
extern NSString* const kSigninPromoPrimaryButtonId;
extern NSString* const kSigninPromoSecondaryButtonId;
extern NSString* const kSigninPromoCloseButtonId;
// This class creates an image view, a label and 2 buttons. This view can be // This class creates an image view, a label and 2 buttons. This view can be
// configured with 2 modes : "Cold State" and "Warm State". // configured with 2 modes : "Cold State" and "Warm State".
// + "Cold State" mode displays the chomium icon in the image view, and only // + "Cold State" mode displays the chomium icon in the image view, and only
......
...@@ -32,6 +32,12 @@ const CGFloat kProfileImageFixedSize = 48; ...@@ -32,6 +32,12 @@ const CGFloat kProfileImageFixedSize = 48;
const CGFloat kButtonHeight = 36; const CGFloat kButtonHeight = 36;
} }
NSString* const kSigninPromoViewId = @"signin_promo_view";
NSString* const kSigninPromoPrimaryButtonId = @"signin_promo_primary_button";
NSString* const kSigninPromoSecondaryButtonId =
@"signin_promo_secondary_button";
NSString* const kSigninPromoCloseButtonId = @"signin_promo_close_button";
@implementation SigninPromoView { @implementation SigninPromoView {
NSArray<NSLayoutConstraint*>* _coldStateConstraints; NSArray<NSLayoutConstraint*>* _coldStateConstraints;
NSArray<NSLayoutConstraint*>* _warmStateConstraints; NSArray<NSLayoutConstraint*>* _warmStateConstraints;
...@@ -50,6 +56,7 @@ const CGFloat kButtonHeight = 36; ...@@ -50,6 +56,7 @@ const CGFloat kButtonHeight = 36;
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
self.isAccessibilityElement = YES; self.isAccessibilityElement = YES;
self.accessibilityIdentifier = kSigninPromoViewId;
// Adding subviews. // Adding subviews.
self.clipsToBounds = YES; self.clipsToBounds = YES;
...@@ -63,7 +70,7 @@ const CGFloat kButtonHeight = 36; ...@@ -63,7 +70,7 @@ const CGFloat kButtonHeight = 36;
_primaryButton = [[MDCFlatButton alloc] init]; _primaryButton = [[MDCFlatButton alloc] init];
_primaryButton.translatesAutoresizingMaskIntoConstraints = NO; _primaryButton.translatesAutoresizingMaskIntoConstraints = NO;
_primaryButton.accessibilityIdentifier = @"signin_promo_primary_button"; _primaryButton.accessibilityIdentifier = kSigninPromoPrimaryButtonId;
_primaryButton.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail; _primaryButton.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[_primaryButton addTarget:self [_primaryButton addTarget:self
action:@selector(onPrimaryButtonAction:) action:@selector(onPrimaryButtonAction:)
...@@ -72,7 +79,7 @@ const CGFloat kButtonHeight = 36; ...@@ -72,7 +79,7 @@ const CGFloat kButtonHeight = 36;
_secondaryButton = [[MDCFlatButton alloc] init]; _secondaryButton = [[MDCFlatButton alloc] init];
_secondaryButton.translatesAutoresizingMaskIntoConstraints = NO; _secondaryButton.translatesAutoresizingMaskIntoConstraints = NO;
_secondaryButton.accessibilityIdentifier = @"signin_promo_secondary_button"; _secondaryButton.accessibilityIdentifier = kSigninPromoSecondaryButtonId;
[_secondaryButton addTarget:self [_secondaryButton addTarget:self
action:@selector(onSecondaryButtonAction:) action:@selector(onSecondaryButtonAction:)
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
...@@ -80,7 +87,7 @@ const CGFloat kButtonHeight = 36; ...@@ -80,7 +87,7 @@ const CGFloat kButtonHeight = 36;
_closeButton = [[UIButton alloc] init]; _closeButton = [[UIButton alloc] init];
_closeButton.translatesAutoresizingMaskIntoConstraints = NO; _closeButton.translatesAutoresizingMaskIntoConstraints = NO;
_closeButton.accessibilityIdentifier = @"signin_promo_close_button"; _closeButton.accessibilityIdentifier = kSigninPromoCloseButtonId;
[self addSubview:_closeButton]; [self addSubview:_closeButton];
// Adding style. // Adding style.
......
...@@ -187,6 +187,7 @@ source_set("eg_tests") { ...@@ -187,6 +187,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/bookmarks:bookmarks_utils", "//ios/chrome/browser/bookmarks:bookmarks_utils",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ui", "//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/authentication:authentication_ui",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/toolbar", "//ios/chrome/browser/ui/toolbar",
"//ios/chrome/browser/ui/tools_menu", "//ios/chrome/browser/ui/tools_menu",
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/experimental_flags.h" #include "ios/chrome/browser/experimental_flags.h"
#include "ios/chrome/browser/pref_names.h" #include "ios/chrome/browser/pref_names.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view.h"
#import "ios/chrome/browser/ui/commands/generic_chrome_command.h" #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h" #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
#import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h"
...@@ -1095,16 +1096,16 @@ id<GREYMatcher> ActionSheet(Action action) { ...@@ -1095,16 +1096,16 @@ id<GREYMatcher> ActionSheet(Action action) {
}]; }];
// Check that promo is visible. // Check that promo is visible.
[BookmarksTestCase verifyPromoAlreadySeen:NO]; [BookmarksTestCase verifyPromoAlreadySeen:NO];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(kSigninPromoViewId)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_sufficientlyVisible()];
// Tap the dismiss button. // Tap the dismiss button.
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_accessibilityID(@"promo_no_thanks_button")] selectElementWithMatcher:grey_accessibilityID(kSigninPromoCloseButtonId)]
performAction:grey_tap()]; performAction:grey_tap()];
// Wait until promo is gone. // Wait until promo is gone.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(kSigninPromoViewId)]
assertWithMatcher:grey_notVisible()]; assertWithMatcher:grey_notVisible()];
// Check that the promo already seen state is updated. // Check that the promo already seen state is updated.
...@@ -1126,12 +1127,17 @@ id<GREYMatcher> ActionSheet(Action action) { ...@@ -1126,12 +1127,17 @@ id<GREYMatcher> ActionSheet(Action action) {
// Check that promo is visible. // Check that promo is visible.
[BookmarksTestCase verifyPromoAlreadySeen:NO]; [BookmarksTestCase verifyPromoAlreadySeen:NO];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")] [[EarlGrey
selectElementWithMatcher:grey_allOf(
grey_accessibilityID(kSigninPromoViewId),
grey_sufficientlyVisible(), nil)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
// Tap the Sign in button. // Tap the Sign in button.
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_accessibilityID(@"promo_sign_in_button")] selectElementWithMatcher:grey_allOf(grey_accessibilityID(
kSigninPromoSecondaryButtonId),
grey_sufficientlyVisible(), nil)]
performAction:grey_tap()]; performAction:grey_tap()];
// Tap the CANCEL button. // Tap the CANCEL button.
...@@ -1141,7 +1147,10 @@ id<GREYMatcher> ActionSheet(Action action) { ...@@ -1141,7 +1147,10 @@ id<GREYMatcher> ActionSheet(Action action) {
uppercaseString])] performAction:grey_tap()]; uppercaseString])] performAction:grey_tap()];
// Check that the bookmarks UI reappeared and the cell is still here. // Check that the bookmarks UI reappeared and the cell is still here.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"promo_view")] [[EarlGrey
selectElementWithMatcher:grey_allOf(
grey_accessibilityID(kSigninPromoViewId),
grey_sufficientlyVisible(), nil)]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
[BookmarksTestCase verifyPromoAlreadySeen:NO]; [BookmarksTestCase verifyPromoAlreadySeen:NO];
......
...@@ -207,6 +207,7 @@ source_set("eg_tests") { ...@@ -207,6 +207,7 @@ source_set("eg_tests") {
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ui/authentication:authentication_ui",
"//ios/chrome/browser/ui/settings", "//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/tools_menu", "//ios/chrome/browser/ui/tools_menu",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view.h"
#import "ios/chrome/browser/ui/history/history_entry_item.h" #import "ios/chrome/browser/ui/history/history_entry_item.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h"
...@@ -145,8 +146,8 @@ void MockSignIn() { ...@@ -145,8 +146,8 @@ void MockSignIn() {
identity); identity);
[ChromeEarlGreyUI openSettingsMenu]; [ChromeEarlGreyUI openSettingsMenu];
[[EarlGrey [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
selectElementWithMatcher:grey_accessibilityID(kSettingsSignInCellId)] kSigninPromoSecondaryButtonId)]
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey [[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabel( selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabel(
......
...@@ -51,6 +51,7 @@ source_set("eg_tests") { ...@@ -51,6 +51,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/bookmarks:bookmarks_utils", "//ios/chrome/browser/bookmarks:bookmarks_utils",
"//ios/chrome/browser/signin", "//ios/chrome/browser/signin",
"//ios/chrome/browser/sync", "//ios/chrome/browser/sync",
"//ios/chrome/browser/ui/authentication:authentication_ui",
"//ios/chrome/browser/ui/settings", "//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/tools_menu", "//ios/chrome/browser/ui/tools_menu",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "ios/chrome/browser/signin/authentication_service.h" #include "ios/chrome/browser/signin/authentication_service.h"
#include "ios/chrome/browser/signin/authentication_service_factory.h" #include "ios/chrome/browser/signin/authentication_service_factory.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view.h"
#import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h" #import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h"
#include "ios/chrome/browser/ui/tools_menu/tools_menu_constants.h" #include "ios/chrome/browser/ui/tools_menu/tools_menu_constants.h"
#import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h"
...@@ -61,7 +62,7 @@ ChromeIdentity* GetFakeIdentity1() { ...@@ -61,7 +62,7 @@ ChromeIdentity* GetFakeIdentity1() {
void OpenSignInFromSettings() { void OpenSignInFromSettings() {
[ChromeEarlGreyUI openSettingsMenu]; [ChromeEarlGreyUI openSettingsMenu];
id<GREYMatcher> matcher = id<GREYMatcher> matcher =
grey_allOf(grey_accessibilityID(kSettingsSignInCellId), grey_allOf(grey_accessibilityID(kSigninPromoSecondaryButtonId),
grey_sufficientlyVisible(), nil); grey_sufficientlyVisible(), nil);
[[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()]; [[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()];
} }
......
...@@ -66,6 +66,7 @@ source_set("test_support") { ...@@ -66,6 +66,7 @@ source_set("test_support") {
"//ios/chrome/browser/sync", "//ios/chrome/browser/sync",
"//ios/chrome/browser/tabs", "//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui:ui_internal", "//ios/chrome/browser/ui:ui_internal",
"//ios/chrome/browser/ui/authentication:authentication_ui",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/main", "//ios/chrome/browser/ui/main",
"//ios/chrome/browser/ui/ntp:ntp_controller", "//ios/chrome/browser/ui/ntp:ntp_controller",
......
...@@ -25,6 +25,10 @@ void TearDownMockAccountReconcilor(); ...@@ -25,6 +25,10 @@ void TearDownMockAccountReconcilor();
// the accounts were correctly removed from the keychain. // the accounts were correctly removed from the keychain.
bool SignOutAndClearAccounts(); bool SignOutAndClearAccounts();
// Resets Sign-in promo impression preferences for bookmarks and settings view,
// and resets kIosBookmarkPromoAlreadySeen flag for bookmarks.
void ResetSigninPromoPreferences();
} // namespace chrome_test_util } // namespace chrome_test_util
#endif // IOS_CHROME_TEST_APP_SIGNIN_TEST_UTIL_H_ #endif // IOS_CHROME_TEST_APP_SIGNIN_TEST_UTIL_H_
...@@ -12,10 +12,12 @@ ...@@ -12,10 +12,12 @@
#include "components/signin/core/common/signin_pref_names.h" #include "components/signin/core/common/signin_pref_names.h"
#include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_constants.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/signin/account_tracker_service_factory.h" #include "ios/chrome/browser/signin/account_tracker_service_factory.h"
#import "ios/chrome/browser/signin/authentication_service.h" #import "ios/chrome/browser/signin/authentication_service.h"
#include "ios/chrome/browser/signin/authentication_service_factory.h" #include "ios/chrome/browser/signin/authentication_service_factory.h"
#include "ios/chrome/browser/signin/gaia_auth_fetcher_ios.h" #include "ios/chrome/browser/signin/gaia_auth_fetcher_ios.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/public/provider/chrome/browser/chrome_browser_provider.h" #import "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h" #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h"
...@@ -172,4 +174,12 @@ bool SignOutAndClearAccounts() { ...@@ -172,4 +174,12 @@ bool SignOutAndClearAccounts() {
return !identity_service->HasIdentities(); return !identity_service->HasIdentities();
} }
void ResetSigninPromoPreferences() {
ios::ChromeBrowserState* browser_state = GetOriginalBrowserState();
PrefService* prefs = browser_state->GetPrefs();
prefs->SetInteger(prefs::kIosBookmarkSigninPromoDisplayedCount, 0);
prefs->SetBoolean(prefs::kIosBookmarkPromoAlreadySeen, false);
prefs->SetInteger(prefs::kIosSettingsSigninPromoDisplayedCount, 0);
}
} // namespace chrome_test_util } // namespace chrome_test_util
...@@ -180,6 +180,7 @@ source_set("test_support") { ...@@ -180,6 +180,7 @@ source_set("test_support") {
deps = [ deps = [
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//components/signin/core/common",
"//components/strings", "//components/strings",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/ui", "//ios/chrome/browser/ui",
......
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
#import <EarlGrey/EarlGrey.h> #import <EarlGrey/EarlGrey.h>
#include "base/command_line.h"
#include "base/mac/scoped_block.h" #include "base/mac/scoped_block.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "components/signin/core/common/signin_switches.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#include "ios/chrome/test/app/settings_test_util.h" #include "ios/chrome/test/app/settings_test_util.h"
#include "ios/chrome/test/app/signin_test_util.h" #include "ios/chrome/test/app/signin_test_util.h"
...@@ -163,6 +165,7 @@ const CFTimeInterval kDrainTimeout = 5; ...@@ -163,6 +165,7 @@ const CFTimeInterval kDrainTimeout = 5;
_isMockAuthenticationDisabled = NO; _isMockAuthenticationDisabled = NO;
_tearDownHandler = nil; _tearDownHandler = nil;
chrome_test_util::ResetSigninPromoPreferences();
chrome_test_util::OpenNewTab(); chrome_test_util::OpenNewTab();
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
} }
...@@ -247,6 +250,11 @@ const CFTimeInterval kDrainTimeout = 5; ...@@ -247,6 +250,11 @@ const CFTimeInterval kDrainTimeout = 5;
} }
+ (void)enableMockAuthentication { + (void)enableMockAuthentication {
// Enable sign-in promo for all tests.
// TODO(crbug.com/739910): Remove this line when the sign-in promo is enabled
// by default.
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableSigninPromo);
chrome_test_util::SetUpMockAuthentication(); chrome_test_util::SetUpMockAuthentication();
chrome_test_util::SetUpMockAccountReconcilor(); chrome_test_util::SetUpMockAccountReconcilor();
chrome_test_util::SetUpFakeSyncServer(); chrome_test_util::SetUpFakeSyncServer();
......
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