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

[iOS] Adding support for unified consent in SigninEarlGreyUI

Adapting helper methods in SigninEarlGreyUI to sign-in when
signin::kUnifiedConsent is enabled.

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ie661295d002baf4143757f1f385518cee3d634ce
Reviewed-on: https://chromium-review.googlesource.com/1140293Reviewed-by: default avatarThomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576440}
parent 842893e6
......@@ -177,8 +177,10 @@ source_set("eg_test_support") {
"unified_consent",
"//components/signin/core/browser",
"//components/signin/core/browser:account_info",
"//components/unified_consent",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/signin",
"//ios/chrome/browser/ui/authentication/unified_consent:unified_consent_ui",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin",
......
......@@ -6,8 +6,11 @@
#import <EarlGrey/EarlGrey.h>
#include "components/unified_consent/feature.h"
#include "ios/chrome/browser/ui/authentication/signin_confirmation_view_controller.h"
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.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/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity.h"
......@@ -33,7 +36,18 @@ using chrome_test_util::SettingsDoneButton;
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI
tapSettingsMenuButton:chrome_test_util::SecondarySignInButton()];
[self selectIdentityWithEmail:identity.userEmail];
if (base::FeatureList::IsEnabled(unified_consent::kUnifiedConsent)) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kIdentityPickerViewIdentifier)]
performAction:grey_tap()];
[[EarlGrey
selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(
identity.userEmail),
grey_sufficientlyVisible(), nil)]
performAction:grey_tap()];
} else {
[self selectIdentityWithEmail:identity.userEmail];
}
[self confirmSigninConfirmationDialog];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
......@@ -58,9 +72,15 @@ using chrome_test_util::SettingsDoneButton;
// Wait until the sync confirmation is displayed.
id<GREYMatcher> signinUICollectionViewMatcher = nil;
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
signinUICollectionViewMatcher = grey_allOf(
grey_ancestor(grey_accessibilityID(kSigninConfirmationCollectionViewId)),
grey_kindOfClass([UICollectionView class]), nil);
if (base::FeatureList::IsEnabled(unified_consent::kUnifiedConsent)) {
signinUICollectionViewMatcher =
grey_accessibilityID(kUnifiedConsentScrollViewIdentifier);
} else {
signinUICollectionViewMatcher = grey_allOf(
grey_ancestor(
grey_accessibilityID(kSigninConfirmationCollectionViewId)),
grey_kindOfClass([UICollectionView class]), nil);
}
[[EarlGrey selectElementWithMatcher:signinUICollectionViewMatcher]
performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];
......
......@@ -7,6 +7,9 @@
#import <UIKit/UIKit.h>
// Accessibility identifier.
extern NSString* const kIdentityPickerViewIdentifier;
// Displays the name, email and avatar of a chrome identity, as a control.
// An down arrow is also displayed on the right of the control, to invite the
// user to tap and select another chrome identity. To get the tap event, see:
......
......@@ -14,6 +14,9 @@
#error "This file requires ARC support."
#endif
NSString* const kIdentityPickerViewIdentifier =
@"kIdentityPickerViewIdentifier";
namespace {
const CGFloat kIdentityPickerViewRadius = 8.;
......@@ -43,6 +46,7 @@ const int kHeaderBackgroundColor = 0xf1f3f4;
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.accessibilityIdentifier = kIdentityPickerViewIdentifier;
self.layer.cornerRadius = kIdentityPickerViewRadius;
self.backgroundColor = UIColorFromRGB(kHeaderBackgroundColor);
// Adding view elements inside.
......
......@@ -9,6 +9,9 @@
#include <vector>
// Accessibility identifier for |-UnifiedConsentViewController.view|.
extern NSString* const kUnifiedConsentScrollViewIdentifier;
@class UnifiedConsentViewController;
// Delegate protocol for UnifiedConsentViewController.
......
......@@ -22,6 +22,9 @@
#error "This file requires ARC support."
#endif
NSString* const kUnifiedConsentScrollViewIdentifier =
@"kUnifiedConsentScrollViewIdentifier";
namespace {
// Sizes.
......@@ -167,6 +170,7 @@ NSString* const kSyncCompleteIconName = @"ic_sync_complete";
// Main scroll view.
self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
self.scrollView.translatesAutoresizingMaskIntoConstraints = NO;
self.scrollView.accessibilityIdentifier = kUnifiedConsentScrollViewIdentifier;
if (@available(iOS 11, *)) {
// The observed behavior was buggy. When the view appears on the screen,
// the scrollvie was not scrolled all the way to the top. Adjusting the
......
......@@ -11,6 +11,7 @@ include_rules = [
"+components/prefs",
"+components/signin/core/browser",
"+components/sync",
"+components/unified_consent",
"+components/variations",
"+components/version_info",
"+google_apis",
......
......@@ -235,6 +235,7 @@ source_set("test_support") {
"//base/test:test_support",
"//components/signin/core/browser",
"//components/strings",
"//components/unified_consent",
"//ios/chrome/app/strings",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/authentication:authentication",
......
......@@ -11,6 +11,7 @@
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "components/strings/grit/components_strings.h"
#include "components/unified_consent/feature.h"
#import "ios/chrome/browser/ui/authentication/signin_promo_view.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_ui_constants.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item.h"
......@@ -292,8 +293,10 @@ id<GREYMatcher> AccountConsistencySetupSigninButton() {
}
id<GREYMatcher> AccountConsistencyConfirmationOkButton() {
return ButtonWithAccessibilityLabelId(
IDS_IOS_ACCOUNT_CONSISTENCY_CONFIRMATION_OK_BUTTON);
int labelID = base::FeatureList::IsEnabled(unified_consent::kUnifiedConsent)
? IDS_IOS_ACCOUNT_UNIFIED_CONSENT_OK_BUTTON
: IDS_IOS_ACCOUNT_CONSISTENCY_CONFIRMATION_OK_BUTTON;
return ButtonWithAccessibilityLabelId(labelID);
}
id<GREYMatcher> AddAccountButton() {
......
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