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

[iOS] Adding -[SigninEarlGreyUI signOutWithManagedAccount:]

Adding -[SigninEarlGreyUI signOutWithManagedAccount:] and removing
some calls for TapButtonWithLabelId().

Bug: 684817
Change-Id: Ie99d6c64eb5566e9f423f19e0b856b32c6d8d525
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795584Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Auto-Submit: Jérôme Lebel <jlebel@chromium.org>
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695203}
parent 76278063
...@@ -37,12 +37,10 @@ ...@@ -37,12 +37,10 @@
using chrome_test_util::AccountsSyncButton; using chrome_test_util::AccountsSyncButton;
using chrome_test_util::ButtonWithAccessibilityLabel; using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId; using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::ClearBrowsingDataView;
using chrome_test_util::GoogleServicesSettingsButton; using chrome_test_util::GoogleServicesSettingsButton;
using chrome_test_util::SettingsAccountButton; using chrome_test_util::SettingsAccountButton;
using chrome_test_util::SettingsDoneButton; using chrome_test_util::SettingsDoneButton;
using chrome_test_util::SettingsMenuPrivacyButton; using chrome_test_util::SettingsMenuPrivacyButton;
using chrome_test_util::SignOutAccountsButton;
using chrome_test_util::SyncSwitchCell; using chrome_test_util::SyncSwitchCell;
using chrome_test_util::TurnSyncSwitchOn; using chrome_test_util::TurnSyncSwitchOn;
......
...@@ -47,6 +47,10 @@ ...@@ -47,6 +47,10 @@
// Checks that the sign-in promo view is not visible. // Checks that the sign-in promo view is not visible.
+ (void)checkSigninPromoNotVisible; + (void)checkSigninPromoNotVisible;
// Signs out from the current identity. if |isManagedAccount| is true, the
// confirmed managed dialog is confirmed while signing out.
+ (void)signOutWithManagedAccount:(BOOL)isManagedAccount;
@end @end
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_EARL_GREY_UI_H_ #endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_EARL_GREY_UI_H_
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_matchers_app_interface.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/chrome_identity.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"
...@@ -47,7 +48,9 @@ using chrome_test_util::AccountConsistencyConfirmationOkButton; ...@@ -47,7 +48,9 @@ using chrome_test_util::AccountConsistencyConfirmationOkButton;
using chrome_test_util::ButtonWithAccessibilityLabel; using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::PrimarySignInButton; using chrome_test_util::PrimarySignInButton;
using chrome_test_util::SecondarySignInButton; using chrome_test_util::SecondarySignInButton;
using chrome_test_util::SettingsAccountButton;
using chrome_test_util::SettingsDoneButton; using chrome_test_util::SettingsDoneButton;
using chrome_test_util::SignOutAccountsButton;
using chrome_test_util::UnifiedConsentAddAccountButton; using chrome_test_util::UnifiedConsentAddAccountButton;
@implementation SigninEarlGreyUI @implementation SigninEarlGreyUI
...@@ -197,4 +200,25 @@ using chrome_test_util::UnifiedConsentAddAccountButton; ...@@ -197,4 +200,25 @@ using chrome_test_util::UnifiedConsentAddAccountButton;
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
} }
+ (void)signOutWithManagedAccount:(BOOL)isManagedAccount {
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsAccountButton()];
[ChromeEarlGreyUI tapAccountsMenuButton:SignOutAccountsButton()];
int confirmationLabelID = 0;
if (isManagedAccount) {
confirmationLabelID = IDS_IOS_MANAGED_DISCONNECT_DIALOG_ACCEPT_UNITY;
} else {
confirmationLabelID = IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE;
}
id<GREYMatcher> confirmationButtonMatcher = [ChromeMatchersAppInterface
buttonWithAccessibilityLabelID:confirmationLabelID];
[[EarlGrey selectElementWithMatcher:confirmationButtonMatcher]
performAction:grey_tap()];
// Wait until the user is signed out.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
[SigninEarlGreyUtils checkSignedOut];
}
@end @end
...@@ -41,7 +41,6 @@ source_set("eg_test_support") { ...@@ -41,7 +41,6 @@ source_set("eg_test_support") {
"//base/test:test_support", "//base/test:test_support",
"//components/unified_consent", "//components/unified_consent",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/ui/authentication:eg_test_support",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin:test_support", "//ios/public/provider/chrome/browser/signin:test_support",
......
...@@ -130,27 +130,9 @@ void RemoveBrowsingData() { ...@@ -130,27 +130,9 @@ void RemoveBrowsingData() {
// Sign in to |identity|. // Sign in to |identity|.
[SigninEarlGreyUI signinWithIdentity:identity]; [SigninEarlGreyUI signinWithIdentity:identity];
[ChromeEarlGreyUI openSettingsMenu];
// Go to Accounts Settings and tap the sign out button.
[[EarlGrey selectElementWithMatcher:chrome_test_util::SettingsAccountButton()]
performAction:grey_tap()];
const CGFloat scroll_displacement = 100.0;
[[[EarlGrey
selectElementWithMatcher:grey_allOf(
chrome_test_util::SignOutAccountsButton(),
grey_interactable(), nil)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
scroll_displacement)
onElementWithMatcher:chrome_test_util::SettingsAccountsCollectionView()]
performAction:grey_tap()];
TapButtonWithLabelId(IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
// Check that there is no signed in user. // Sign out.
[SigninEarlGreyUtils checkSignedOut]; [SigninEarlGreyUI signOutWithManagedAccount:NO];
} }
// Tests that signing out of a managed account from the Settings works // Tests that signing out of a managed account from the Settings works
...@@ -176,22 +158,8 @@ void RemoveBrowsingData() { ...@@ -176,22 +158,8 @@ void RemoveBrowsingData() {
[SigninEarlGreyUI confirmSigninConfirmationDialog]; [SigninEarlGreyUI confirmSigninConfirmationDialog];
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity];
// Go to Accounts Settings and tap the sign out button. // Sign out.
[[EarlGrey selectElementWithMatcher:chrome_test_util::SettingsAccountButton()] [SigninEarlGreyUI signOutWithManagedAccount:YES];
performAction:grey_tap()];
const CGFloat scroll_displacement = 100.0;
[[[EarlGrey
selectElementWithMatcher:grey_allOf(
chrome_test_util::SignOutAccountsButton(),
grey_interactable(), nil)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
scroll_displacement)
onElementWithMatcher:chrome_test_util::SettingsAccountsCollectionView()]
performAction:grey_tap()];
TapButtonWithLabelId(IDS_IOS_MANAGED_DISCONNECT_DIALOG_ACCEPT);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
// Check that there is no signed in user. // Check that there is no signed in user.
[SigninEarlGreyUtils checkSignedOut]; [SigninEarlGreyUtils checkSignedOut];
...@@ -281,25 +249,12 @@ void RemoveBrowsingData() { ...@@ -281,25 +249,12 @@ void RemoveBrowsingData() {
// effectively block the authentication flow, ensuring that the authentication // effectively block the authentication flow, ensuring that the authentication
// flow is always still running when the sign-in is being cancelled. // flow is always still running when the sign-in is being cancelled.
[SigninEarlGreyUI signinWithIdentity:identity2]; [SigninEarlGreyUI signinWithIdentity:identity2];
[ChromeEarlGreyUI openSettingsMenu];
// Go to Accounts Settings and tap the sign out button. // Sign out.
[[EarlGrey selectElementWithMatcher:chrome_test_util::SettingsAccountButton()] [SigninEarlGreyUI signOutWithManagedAccount:NO];
performAction:grey_tap()];
const CGFloat scroll_displacement = 100.0;
[[[EarlGrey
selectElementWithMatcher:grey_allOf(
chrome_test_util::SignOutAccountsButton(),
grey_interactable(), nil)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
scroll_displacement)
onElementWithMatcher:chrome_test_util::SettingsAccountsCollectionView()]
performAction:grey_tap()];
TapButtonWithLabelId(IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE);
[SigninEarlGreyUtils checkSignedOut];
// Sign in with |identity1|. // Sign in with |identity1|.
[ChromeEarlGreyUI openSettingsMenu];
[[EarlGrey selectElementWithMatcher:SecondarySignInButton()] [[EarlGrey selectElementWithMatcher:SecondarySignInButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[SigninEarlGreyUI selectIdentityWithEmail:identity1.userEmail]; [SigninEarlGreyUI selectIdentityWithEmail:identity1.userEmail];
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#include "components/unified_consent/feature.h" #include "components/unified_consent/feature.h"
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h"
......
...@@ -45,25 +45,6 @@ id<GREYMatcher> identityChooserButtonMatcherWithEmail(NSString* userEmail) { ...@@ -45,25 +45,6 @@ id<GREYMatcher> identityChooserButtonMatcherWithEmail(NSString* userEmail) {
grey_sufficientlyVisible(), nil); grey_sufficientlyVisible(), nil);
} }
// Opens Accounts Settings and tap the sign out button. Assumes that the main
// settings page is visible.
void SignOutFromSettings() {
[[EarlGrey selectElementWithMatcher:chrome_test_util::SettingsAccountButton()]
performAction:grey_tap()];
const CGFloat scroll_displacement = 100.0;
[[[EarlGrey
selectElementWithMatcher:grey_allOf(
chrome_test_util::SignOutAccountsButton(),
grey_interactable(), nil)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
scroll_displacement)
onElementWithMatcher:chrome_test_util::SettingsAccountsCollectionView()]
performAction:grey_tap()];
TapButtonWithLabelId(IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE);
[SigninEarlGreyUtils checkSignedOut];
}
} // namespace } // namespace
// Sign-in interactions tests that require Unified Consent to be enabled. // Sign-in interactions tests that require Unified Consent to be enabled.
...@@ -140,10 +121,10 @@ void SignOutFromSettings() { ...@@ -140,10 +121,10 @@ void SignOutFromSettings() {
identity_service->AddIdentity(identity2); identity_service->AddIdentity(identity2);
[SigninEarlGreyUI signinWithIdentity:identity1]; [SigninEarlGreyUI signinWithIdentity:identity1];
[ChromeEarlGreyUI openSettingsMenu]; [SigninEarlGreyUI signOutWithManagedAccount:NO];
SignOutFromSettings();
// Sign in with |identity2|. // Sign in with |identity2|.
[ChromeEarlGreyUI openSettingsMenu];
[[EarlGrey selectElementWithMatcher:SecondarySignInButton()] [[EarlGrey selectElementWithMatcher:SecondarySignInButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[SigninEarlGreyUI selectIdentityWithEmail:identity2.userEmail]; [SigninEarlGreyUI selectIdentityWithEmail:identity2.userEmail];
...@@ -185,10 +166,10 @@ void SignOutFromSettings() { ...@@ -185,10 +166,10 @@ void SignOutFromSettings() {
// Sign in to |identity1|. // Sign in to |identity1|.
[SigninEarlGreyUI signinWithIdentity:identity1]; [SigninEarlGreyUI signinWithIdentity:identity1];
[ChromeEarlGreyUI openSettingsMenu]; [SigninEarlGreyUI signOutWithManagedAccount:NO];
SignOutFromSettings();
// Sign in with |identity2|. // Sign in with |identity2|.
[ChromeEarlGreyUI openSettingsMenu];
[[EarlGrey selectElementWithMatcher:SecondarySignInButton()] [[EarlGrey selectElementWithMatcher:SecondarySignInButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[SigninEarlGreyUI selectIdentityWithEmail:identity2.userEmail]; [SigninEarlGreyUI selectIdentityWithEmail:identity2.userEmail];
......
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