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

[iOS] Adding -[SigninEarlGreyUI signinWithIdentity:isManagedAccount:]

Adding -[SigninEarlGreyUI signinWithIdentity:isManagedAccount:]. And
removing a call to TapButtonWithLabelId().

Bug: 684817
Change-Id: I8951ec6ec36ac9fd6c8b976d1e72ff1dd65fb486
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1793090
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695610}
parent 27376043
......@@ -164,7 +164,9 @@ source_set("eg_test_support") {
"//ios/chrome/browser/ui/authentication/cells",
"//ios/chrome/browser/ui/authentication/unified_consent:unified_consent_ui",
"//ios/chrome/browser/ui/authentication/unified_consent/identity_chooser:identity_chooser_ui",
"//ios/chrome/browser/ui/signin_interaction:eg_test_support",
"//ios/chrome/browser/ui/util",
"//ios/chrome/test:eg_test_support",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin",
......
......@@ -14,9 +14,15 @@
// Methods used for the EarlGrey tests, related to UI.
@interface SigninEarlGreyUI : NSObject
// Adds the identity (if not already added), and perform a sign-in.
// Calls [SigninEarlGreyUI signinWithIdentity:identity isManagedAccount:NO].
+ (void)signinWithIdentity:(ChromeIdentity*)identity;
// Adds the identity (if not already added), and perform a sign-in. if
// |isManagedAccount| is true, |identity| needs to be a managed account and the
// managed dialog is expected while signing in.
+ (void)signinWithIdentity:(ChromeIdentity*)identity
isManagedAccount:(BOOL)isManagedAccount;
// Taps on the settings link in the sign-in view. The sign-in view has to be
// opened before calling this method.
+ (void)tapSettingsLink;
......@@ -25,6 +31,9 @@
// is confirmed, but it doesn't validated the user consent page.
+ (void)selectIdentityWithEmail:(NSString*)userEmail;
// Confirms the managed account dialog with signing in.
+ (void)confirmSigninWithManagedAccount;
// Confirms the sign in confirmation page, scrolls first to make the OK button
// visible on short devices (e.g. iPhone 5s).
+ (void)confirmSigninConfirmationDialog;
......
......@@ -11,11 +11,13 @@
#import "ios/chrome/browser/ui/authentication/unified_consent/identity_chooser/identity_chooser_cell.h"
#import "ios/chrome/browser/ui/authentication/unified_consent/identity_picker_view.h"
#import "ios/chrome/browser/ui/authentication/unified_consent/unified_consent_view_controller.h"
#import "ios/chrome/browser/ui/signin_interaction/signin_interaction_controller_egtest_util.h"
#import "ios/chrome/browser/ui/util/transparent_link_button.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_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_matchers_app_interface.h"
#import "ios/chrome/test/scoped_eg_synchronization_disabler.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h"
......@@ -56,6 +58,11 @@ using chrome_test_util::UnifiedConsentAddAccountButton;
@implementation SigninEarlGreyUI
+ (void)signinWithIdentity:(ChromeIdentity*)identity {
[self signinWithIdentity:(ChromeIdentity*)identity isManagedAccount:NO];
}
+ (void)signinWithIdentity:(ChromeIdentity*)identity
isManagedAccount:(BOOL)isManagedAccount {
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
identity);
......@@ -64,6 +71,9 @@ using chrome_test_util::UnifiedConsentAddAccountButton;
tapSettingsMenuButton:chrome_test_util::SecondarySignInButton()];
[self selectIdentityWithEmail:identity.userEmail];
[self confirmSigninConfirmationDialog];
if (isManagedAccount) {
[self confirmSigninWithManagedAccount];
}
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
[SigninEarlGreyUtils checkSignedInWithIdentity:identity];
......@@ -90,6 +100,17 @@ using chrome_test_util::UnifiedConsentAddAccountButton;
performAction:grey_tap()];
}
+ (void)confirmSigninWithManagedAccount {
// Synchronization off due to an infinite spinner, in the user consent view,
// under the managed consent dialog. This spinner is started by the sign-in
// process.
ScopedSynchronizationDisabler disabler;
id<GREYMatcher> acceptButton = [ChromeMatchersAppInterface
buttonWithAccessibilityLabelID:IDS_IOS_MANAGED_SIGNIN_ACCEPT_BUTTON];
WaitForMatcher(acceptButton);
[[EarlGrey selectElementWithMatcher:acceptButton] performAction:grey_tap()];
}
+ (void)confirmSigninConfirmationDialog {
// To confirm the dialog, the scroll view content has to be scrolled to the
// bottom to transform "MORE" button into the validation button.
......
......@@ -29,7 +29,6 @@
#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_test_case.h"
#import "ios/chrome/test/scoped_eg_synchronization_disabler.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h"
#import "ios/web/public/web_state.h"
......@@ -139,23 +138,9 @@ void RemoveBrowsingData() {
// correctly.
- (void)testSignInDisconnectFromChromeManaged {
ChromeIdentity* identity = [SigninEarlGreyUtils fakeManagedIdentity];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity(
identity);
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:SecondarySignInButton()];
[SigninEarlGreyUI selectIdentityWithEmail:identity.userEmail];
[SigninEarlGreyUI confirmSigninConfirmationDialog];
{
// Synchronization off due to an infinite spinner.
ScopedSynchronizationDisabler disabler;
WaitForMatcher(chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_MANAGED_SIGNIN_ACCEPT_BUTTON));
TapButtonWithLabelId(IDS_IOS_MANAGED_SIGNIN_ACCEPT_BUTTON);
}
[SigninEarlGreyUtils checkSignedInWithIdentity:identity];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
// Sign-in with a managed account.
[SigninEarlGreyUI signinWithIdentity:identity isManagedAccount:YES];
// Sign out.
[SigninEarlGreyUI signOutWithManagedAccount:YES];
......
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