Commit b2a33988 authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Minimize inconsistencies in SigninEarlGreyUI test APIs.

- Consolidates all button tap actions under 'tap' prefix.
- Consolidates all verification actions under 'verify' prefix.
- Removes single-use methods.

Bug: 1103274
Change-Id: Id398e1c80da233f101a87b9b40eda1b0e45f4bd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362700Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799539}
parent 05d8c11c
......@@ -89,7 +89,7 @@ void ChooseImportOrKeepDataSepareteDialog(id<GREYMatcher> choiceButtonMatcher) {
[[EarlGrey selectElementWithMatcher:SecondarySignInButton()]
performAction:grey_tap()];
[SigninEarlGreyUI selectIdentityWithEmail:fakeIdentity2.userEmail];
[SigninEarlGreyUI confirmSigninConfirmationDialog];
[SigninEarlGreyUI tapSigninConfirmationDialog];
// Switch Sync account to |fakeIdentity2| should ask whether date should be
// imported or kept separate. Choose to keep data separate.
......@@ -250,7 +250,7 @@ void ChooseImportOrKeepDataSepareteDialog(id<GREYMatcher> choiceButtonMatcher) {
// The authentication flow is only created when the confirm button is
// selected. Note that authentication flow actually blocks as the
// "Clear Browsing Before Syncing" dialog is presented.
[SigninEarlGreyUI confirmSigninConfirmationDialog];
[SigninEarlGreyUI tapSigninConfirmationDialog];
// Waits until the merge/delete data panel is shown.
[[EarlGrey selectElementWithMatcher:SettingsImportDataKeepSeparateButton()]
assertWithMatcher:grey_interactable()];
......
......@@ -11,12 +11,6 @@
@class FakeChromeIdentity;
typedef NS_ENUM(NSInteger, SignOutConfirmation) {
SignOutConfirmationManagedUser,
SignOutConfirmationNonManagedUser,
SignOutConfirmationNonManagedUserWithClearedData,
};
// Test methods that perform sign in actions on Chrome UI.
@interface SigninEarlGreyUI : NSObject
......@@ -37,44 +31,43 @@ typedef NS_ENUM(NSInteger, SignOutConfirmation) {
// method or if the account is not successfully signed out.
+ (void)signOutAndClearDataFromDevice;
// Selects an identity when the identity chooser dialog is presented. The dialog
// is confirmed, but it doesn't validated the user consent page.
+ (void)selectIdentityWithEmail:(NSString*)userEmail;
// Taps on the settings link in the sign-in view. The sign-in view has to be
// opened before calling this method.
+ (void)tapSettingsLink;
// Selects an identity when the identity chooser dialog is presented. The dialog
// is confirmed, but it doesn't validated the user consent page.
+ (void)selectIdentityWithEmail:(NSString*)userEmail;
// Deprecated. Use |tapSigninConfirmationDialog|.
+ (void)confirmSigninConfirmationDialog;
// Confirms the sign in confirmation page, scrolls first to make the OK button
// Taps the sign in confirmation page, scrolls first to make the OK button
// visible on short devices (e.g. iPhone 5s).
+ (void)confirmSigninConfirmationDialog;
+ (void)tapSigninConfirmationDialog;
// Taps on the "ADD ACCOUNT" button in the unified consent, to display the
// SSO dialog.
// This method should only be used with UnifiedConsent flag.
+ (void)tapAddAccountButton;
// Taps "Remove account from this device" button and follow-up confirmation.
// Assumes the user is on the Settings screen.
+ (void)tapRemoveAccountFromDeviceWithFakeIdentity:
(FakeChromeIdentity*)fakeIdentity;
// Checks that the sign-in promo view (with a close button) is visible using the
// right mode.
+ (void)checkSigninPromoVisibleWithMode:(SigninPromoViewMode)mode;
+ (void)verifySigninPromoVisibleWithMode:(SigninPromoViewMode)mode;
// Checks that the sign-in promo view is visible using the right mode. If
// |closeButton| is set to YES, the close button in the sign-in promo has to be
// visible.
+ (void)checkSigninPromoVisibleWithMode:(SigninPromoViewMode)mode
closeButton:(BOOL)closeButton;
+ (void)verifySigninPromoVisibleWithMode:(SigninPromoViewMode)mode
closeButton:(BOOL)closeButton;
// Checks that the sign-in promo view is not visible.
+ (void)checkSigninPromoNotVisible;
// Taps the appropriate action label on the sign-out dialog for the given
// |signOutConfirmation| profile and signs out from the current identity.
+ (void)signOutWithSignOutConfirmation:(SignOutConfirmation)signOutConfirmation;
// Taps "Remove account from this device" button and follow-up confirmation.
// Assumes the user is on the Settings screen.
+ (void)tapRemoveAccountFromDeviceWithFakeIdentity:
(FakeChromeIdentity*)fakeIdentity;
+ (void)verifySigninPromoNotVisible;
@end
......
......@@ -40,9 +40,16 @@ using chrome_test_util::SignOutAccountsButton;
[ChromeEarlGreyUI
tapSettingsMenuButton:chrome_test_util::SecondarySignInButton()];
[self selectIdentityWithEmail:fakeIdentity.userEmail];
[self confirmSigninConfirmationDialog];
[self tapSigninConfirmationDialog];
if ([fakeIdentity.userEmail hasSuffix:ios::kManagedIdentityEmailSuffix]) {
[self 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];
[ChromeEarlGrey waitForMatcher:acceptButton];
[[EarlGrey selectElementWithMatcher:acceptButton] performAction:grey_tap()];
}
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
......@@ -80,18 +87,11 @@ using chrome_test_util::SignOutAccountsButton;
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];
[ChromeEarlGrey waitForMatcher:acceptButton];
[[EarlGrey selectElementWithMatcher:acceptButton] performAction:grey_tap()];
+ (void)confirmSigninConfirmationDialog {
[self tapSigninConfirmationDialog];
}
+ (void)confirmSigninConfirmationDialog {
+ (void)tapSigninConfirmationDialog {
// To confirm the dialog, the scroll view content has to be scrolled to the
// bottom to transform "MORE" button into the validation button.
// EarlGrey fails to scroll to the bottom, using grey_scrollToContentEdge(),
......@@ -149,12 +149,12 @@ using chrome_test_util::SignOutAccountsButton;
[[EarlGrey selectElementWithMatcher:buttonMatcher] performAction:grey_tap()];
}
+ (void)checkSigninPromoVisibleWithMode:(SigninPromoViewMode)mode {
[self checkSigninPromoVisibleWithMode:mode closeButton:YES];
+ (void)verifySigninPromoVisibleWithMode:(SigninPromoViewMode)mode {
[self verifySigninPromoVisibleWithMode:mode closeButton:YES];
}
+ (void)checkSigninPromoVisibleWithMode:(SigninPromoViewMode)mode
closeButton:(BOOL)closeButton {
+ (void)verifySigninPromoVisibleWithMode:(SigninPromoViewMode)mode
closeButton:(BOOL)closeButton {
[ChromeEarlGreyUI waitForAppToIdle];
[[EarlGrey
selectElementWithMatcher:grey_allOf(
......@@ -188,7 +188,7 @@ using chrome_test_util::SignOutAccountsButton;
}
}
+ (void)checkSigninPromoNotVisible {
+ (void)verifySigninPromoNotVisible {
[[EarlGrey
selectElementWithMatcher:grey_allOf(
grey_accessibilityID(kSigninPromoViewId),
......@@ -204,29 +204,6 @@ using chrome_test_util::SignOutAccountsButton;
assertWithMatcher:grey_nil()];
}
+ (void)signOutWithSignOutConfirmation:
(SignOutConfirmation)signOutConfirmation {
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsAccountButton()];
id<GREYMatcher> signOutButtonMatcher;
int confirmationLabelID = 0;
switch (signOutConfirmation) {
case SignOutConfirmationNonManagedUser: {
signOutButtonMatcher = SignOutAccountsButton();
confirmationLabelID = IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE;
break;
}
case SignOutConfirmationManagedUser:
case SignOutConfirmationNonManagedUserWithClearedData: {
signOutButtonMatcher = grey_accessibilityID(
kSettingsAccountsTableViewSignoutAndClearDataCellId);
confirmationLabelID = IDS_IOS_DISCONNECT_DIALOG_CONTINUE_AND_CLEAR_MOBILE;
break;
}
}
}
+ (void)tapRemoveAccountFromDeviceWithFakeIdentity:
(FakeChromeIdentity*)fakeIdentity {
[[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabel(
......
......@@ -66,13 +66,13 @@ using chrome_test_util::SecondarySignInButton;
// Check that sign-in promo view is visible.
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState];
// Go to child node.
[BookmarkEarlGreyUI openMobileBookmarks];
// Wait until promo is gone.
[SigninEarlGreyUI checkSigninPromoNotVisible];
[SigninEarlGreyUI verifySigninPromoNotVisible];
// Check that the promo already seen state is not updated.
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
......@@ -99,7 +99,7 @@ using chrome_test_util::SecondarySignInButton;
// Check that sign-in promo view is visible.
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState];
// Tap the dismiss button.
[[EarlGrey
......@@ -109,7 +109,7 @@ using chrome_test_util::SecondarySignInButton;
performAction:grey_tap()];
// Wait until promo is gone.
[SigninEarlGreyUI checkSigninPromoNotVisible];
[SigninEarlGreyUI verifySigninPromoNotVisible];
// Check that the promo already seen state is updated.
[BookmarkEarlGrey verifyPromoAlreadySeen:YES];
......@@ -124,7 +124,7 @@ using chrome_test_util::SecondarySignInButton;
// Check that sign-in promo view are visible.
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState];
// Tap the primary button.
[[EarlGrey
......@@ -139,7 +139,7 @@ using chrome_test_util::SecondarySignInButton;
// Check that the bookmarks UI reappeared and the cell is still here.
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState];
}
// Tests the tapping on the primary button of sign-in promo view in a warm
......@@ -155,7 +155,7 @@ using chrome_test_util::SecondarySignInButton;
// Check that promo is visible.
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
// Tap the primary button.
[[EarlGrey
......@@ -170,7 +170,7 @@ using chrome_test_util::SecondarySignInButton;
// Check that the bookmarks UI reappeared and the cell is still here.
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
}
......@@ -188,7 +188,7 @@ using chrome_test_util::SecondarySignInButton;
// Check that sign-in promo view are visible.
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
// Tap the secondary button.
[[EarlGrey
......@@ -207,7 +207,7 @@ using chrome_test_util::SecondarySignInButton;
// Check that the bookmarks UI reappeared and the cell is still here.
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
}
// Tests that the sign-in promo should not be shown after been shown 19 times.
......@@ -216,7 +216,7 @@ using chrome_test_util::SecondarySignInButton;
[BookmarkEarlGreyUI openBookmarks];
// Check the sign-in promo view is visible.
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState];
// Check the sign-in promo already-seen state didn't change.
[BookmarkEarlGrey verifyPromoAlreadySeen:NO];
GREYAssertEqual(20, [BookmarkEarlGrey numberOfTimesPromoAlreadySeen],
......@@ -228,7 +228,7 @@ using chrome_test_util::SecondarySignInButton;
[BookmarkEarlGreyUI openBookmarks];
[ChromeEarlGreyUI waitForAppToIdle];
// Check that the sign-in promo is not visible anymore.
[SigninEarlGreyUI checkSigninPromoNotVisible];
[SigninEarlGreyUI verifySigninPromoNotVisible];
}
@end
......@@ -160,13 +160,15 @@ id<GREYMatcher> TitleOfTestPage() {
- (void)testRecentTabSigninPromoReloaded {
OpenRecentTabsPanel();
// Sign-in promo should be visible with cold state.
[SigninEarlGreyUI checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState
closeButton:NO];
[SigninEarlGreyUI
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState
closeButton:NO];
FakeChromeIdentity* fakeIdentity = [SigninEarlGrey fakeIdentity1];
[SigninEarlGrey addFakeIdentity:fakeIdentity];
// Sign-in promo should be visible with warm state.
[SigninEarlGreyUI checkSigninPromoVisibleWithMode:SigninPromoViewModeWarmState
closeButton:NO];
[SigninEarlGreyUI
verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState
closeButton:NO];
[self closeRecentTabs];
[SigninEarlGrey forgetFakeIdentity:fakeIdentity];
}
......@@ -175,8 +177,9 @@ id<GREYMatcher> TitleOfTestPage() {
// crbug.com/776939
- (void)testRecentTabSigninPromoReloadedWhileHidden {
OpenRecentTabsPanel();
[SigninEarlGreyUI checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState
closeButton:NO];
[SigninEarlGreyUI
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState
closeButton:NO];
// Tap on "Other Devices", to hide the sign-in promo.
NSString* otherDevicesLabel =
......@@ -186,7 +189,7 @@ id<GREYMatcher> TitleOfTestPage() {
grey_sufficientlyVisible(), nil);
[[EarlGrey selectElementWithMatcher:otherDevicesMatcher]
performAction:grey_tap()];
[SigninEarlGreyUI checkSigninPromoNotVisible];
[SigninEarlGreyUI verifySigninPromoNotVisible];
// Add an account.
FakeChromeIdentity* fakeIdentity = [SigninEarlGrey fakeIdentity1];
......@@ -195,8 +198,9 @@ id<GREYMatcher> TitleOfTestPage() {
// Tap on "Other Devices", to show the sign-in promo.
[[EarlGrey selectElementWithMatcher:otherDevicesMatcher]
performAction:grey_tap()];
[SigninEarlGreyUI checkSigninPromoVisibleWithMode:SigninPromoViewModeWarmState
closeButton:NO];
[SigninEarlGreyUI
verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState
closeButton:NO];
[self closeRecentTabs];
[SigninEarlGrey forgetFakeIdentity:fakeIdentity];
}
......@@ -274,8 +278,9 @@ id<GREYMatcher> TitleOfTestPage() {
[illustratedCell assertWithMatcher:grey_nil()];
}
[SigninEarlGreyUI checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState
closeButton:NO];
[SigninEarlGreyUI
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState
closeButton:NO];
}
@end
......@@ -42,7 +42,7 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
- (void)testSignInPromoWithColdStateUsingPrimaryButton {
[ChromeEarlGreyUI openSettingsMenu];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState];
[ChromeEarlGreyUI tapSettingsMenuButton:PrimarySignInButton()];
// Cancel the sign-in operation.
......@@ -50,7 +50,7 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
kSkipSigninAccessibilityIdentifier)]
performAction:grey_tap()];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState];
}
// Tests signing in, using the primary button with a warm state.
......@@ -60,13 +60,13 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
[ChromeEarlGreyUI openSettingsMenu];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
[ChromeEarlGreyUI tapSettingsMenuButton:PrimarySignInButton()];
[SigninEarlGreyUI confirmSigninConfirmationDialog];
[SigninEarlGreyUI tapSigninConfirmationDialog];
// User signed in.
[SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity];
[SigninEarlGreyUI checkSigninPromoNotVisible];
[SigninEarlGreyUI verifySigninPromoNotVisible];
[[EarlGrey selectElementWithMatcher:SettingsAccountButton()]
assertWithMatcher:grey_interactable()];
}
......@@ -78,14 +78,14 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
[ChromeEarlGreyUI openSettingsMenu];
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState];
[ChromeEarlGreyUI tapSettingsMenuButton:SecondarySignInButton()];
[SigninEarlGreyUI selectIdentityWithEmail:fakeIdentity.userEmail];
[SigninEarlGreyUI confirmSigninConfirmationDialog];
[SigninEarlGreyUI tapSigninConfirmationDialog];
// User signed in.
[SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity];
[SigninEarlGreyUI checkSigninPromoNotVisible];
[SigninEarlGreyUI verifySigninPromoNotVisible];
[[EarlGrey selectElementWithMatcher:SettingsAccountButton()]
assertWithMatcher:grey_interactable()];
}
......@@ -98,7 +98,7 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
[ChromeEarlGreyUI openSettingsMenu];
// Check the sign-in promo view is visible.
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState];
// Check the sign-in promo will not be shown anymore.
int newDisplayedCount =
[SigninSettingsAppInterface settingsSigninPromoDisplayedCount];
......@@ -109,7 +109,7 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
performAction:grey_tap()];
[ChromeEarlGreyUI openSettingsMenu];
// Check that the sign-in promo is not visible anymore.
[SigninEarlGreyUI checkSigninPromoNotVisible];
[SigninEarlGreyUI verifySigninPromoNotVisible];
[[EarlGrey
selectElementWithMatcher:grey_allOf(
grey_accessibilityID(kSettingsSignInCellId),
......@@ -121,7 +121,7 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
[ChromeEarlGreyUI openSettingsMenu];
// Check the sign-in promo view is visible.
[SigninEarlGreyUI
checkSigninPromoVisibleWithMode:SigninPromoViewModeColdState];
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState];
// Tap on dismiss button.
[[EarlGrey
selectElementWithMatcher:grey_allOf(grey_accessibilityID(
......@@ -129,7 +129,7 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
grey_sufficientlyVisible(), nil)]
performAction:grey_tap()];
// Check that the sign-in promo is not visible anymore.
[SigninEarlGreyUI checkSigninPromoNotVisible];
[SigninEarlGreyUI verifySigninPromoNotVisible];
[[EarlGrey
selectElementWithMatcher:grey_allOf(
grey_accessibilityID(kSettingsSignInCellId),
......
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