Commit fef43018 authored by Yuke Liao's avatar Yuke Liao Committed by Commit Bot

Clean up usages of chrome_test_util::NavigationBarDoneButton()

There are still tests that wraps NavigationBarDoneButton with a local
helper function, which is unnecessary, instead, we should call EarlGrey
explicitly like following:

[[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
      performAction:grey_tap()];

So, this CL cleans them up.

Bug: 741898
Change-Id: I74ea738cb1e58b1ee44da57c1dfaf74b7c348405
Reviewed-on: https://chromium-review.googlesource.com/568271Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMihai Sardarescu (OOO) <msarda@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarMike Baxley <baxley@chromium.org>
Commit-Queue: Yuke Liao <liaoyuke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488490}
parent 0b674fa7
...@@ -415,9 +415,7 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) { ...@@ -415,9 +415,7 @@ void AssertAuthenticatedIdentityInActiveProfile(ChromeIdentity* identity) {
[[EarlGrey selectElementWithMatcher:settings_link_matcher] [[EarlGrey selectElementWithMatcher:settings_link_matcher]
performAction:grey_tap()]; performAction:grey_tap()];
id<GREYMatcher> done_button_matcher = NavigationBarDoneButton(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
WaitForMatcher(done_button_matcher);
[[EarlGrey selectElementWithMatcher:done_button_matcher]
performAction:grey_tap()]; performAction:grey_tap()];
// All Settings should be gone and user signed in. // All Settings should be gone and user signed in.
......
...@@ -38,13 +38,6 @@ using chrome_test_util::SettingsMenuPrivacyButton; ...@@ -38,13 +38,6 @@ using chrome_test_util::SettingsMenuPrivacyButton;
performAction:grey_tap()]; performAction:grey_tap()];
} }
- (void)exitSettingsMenu {
[[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
// Wait for UI components to finish loading.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
// Test that opening the clear browsing data dialog does not cause a crash. // Test that opening the clear browsing data dialog does not cause a crash.
- (void)testOpeningClearBrowsingData { - (void)testOpeningClearBrowsingData {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
...@@ -53,7 +46,8 @@ using chrome_test_util::SettingsMenuPrivacyButton; ...@@ -53,7 +46,8 @@ using chrome_test_util::SettingsMenuPrivacyButton;
[defaults setObject:@"Enabled" forKey:@"EnableNewClearBrowsingDataUI"]; [defaults setObject:@"Enabled" forKey:@"EnableNewClearBrowsingDataUI"];
[self openClearBrowsingDataDialog]; [self openClearBrowsingDataDialog];
[self exitSettingsMenu]; [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
[defaults setObject:oldSetting forKey:@"EnableNewClearBrowsingDataUI"]; [defaults setObject:oldSetting forKey:@"EnableNewClearBrowsingDataUI"];
} }
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
using autofill::PasswordForm; using autofill::PasswordForm;
using chrome_test_util::ButtonWithAccessibilityLabel; using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::SettingsMenuBackButton; using chrome_test_util::SettingsMenuBackButton;
using chrome_test_util::NavigationBarDoneButton;
namespace { namespace {
...@@ -342,13 +343,6 @@ void TapEdit() { ...@@ -342,13 +343,6 @@ void TapEdit() {
performAction:grey_tap()]; performAction:grey_tap()];
} }
// Tap Done in any settings view.
void TapDone() {
[[EarlGrey
selectElementWithMatcher:chrome_test_util::NavigationBarDoneButton()]
performAction:grey_tap()];
}
} // namespace } // namespace
@interface MockReauthenticationModule : NSObject<ReauthenticationProtocol> @interface MockReauthenticationModule : NSObject<ReauthenticationProtocol>
...@@ -431,7 +425,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -431,7 +425,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
TapEdit(); TapEdit();
chrome_test_util::VerifyAccessibilityForCurrentScreen(); chrome_test_util::VerifyAccessibilityForCurrentScreen();
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
// Inspect "password details" view. // Inspect "password details" view.
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
...@@ -442,7 +437,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -442,7 +437,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that attempts to copy a password provide appropriate feedback, // Checks that attempts to copy a password provide appropriate feedback,
...@@ -489,7 +485,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -489,7 +485,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that attempts to copy a username provide appropriate feedback. // Checks that attempts to copy a username provide appropriate feedback.
...@@ -518,7 +515,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -518,7 +515,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that attempts to copy a site URL provide appropriate feedback. // Checks that attempts to copy a site URL provide appropriate feedback.
...@@ -547,7 +545,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -547,7 +545,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that deleting a password from password details view goes back to the // Checks that deleting a password from password details view goes back to the
...@@ -604,7 +603,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -604,7 +603,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that deleting a password from password details can be cancelled. // Checks that deleting a password from password details can be cancelled.
...@@ -652,7 +652,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -652,7 +652,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that if the list view is in edit mode, then the details password view // Checks that if the list view is in edit mode, then the details password view
...@@ -679,7 +680,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -679,7 +680,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that attempts to copy the site via the context menu item provide an // Checks that attempts to copy the site via the context menu item provide an
...@@ -717,7 +719,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -717,7 +719,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that attempts to copy the username via the context menu item provide // Checks that attempts to copy the username via the context menu item provide
...@@ -756,7 +759,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -756,7 +759,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that attempts to copy the password via the context menu item provide // Checks that attempts to copy the password via the context menu item provide
...@@ -802,7 +806,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -802,7 +806,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that attempts to show and hide the password via the context menu item // Checks that attempts to show and hide the password via the context menu item
...@@ -856,7 +861,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -856,7 +861,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that federated credentials have no password but show the federation. // Checks that federated credentials have no password but show the federation.
...@@ -900,7 +906,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -900,7 +906,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks the order of the elements in the detail view layout for a // Checks the order of the elements in the detail view layout for a
...@@ -956,7 +963,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -956,7 +963,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks the order of the elements in the detail view layout for a blacklisted // Checks the order of the elements in the detail view layout for a blacklisted
...@@ -1001,7 +1009,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -1001,7 +1009,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks the order of the elements in the detail view layout for a federated // Checks the order of the elements in the detail view layout for a federated
...@@ -1059,7 +1068,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -1059,7 +1068,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Check that stored entries are shown no matter what the preference for saving // Check that stored entries are shown no matter what the preference for saving
...@@ -1099,7 +1109,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -1099,7 +1109,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Check that toggling the switch for the "save passwords" preference changes // Check that toggling the switch for the "save passwords" preference changes
...@@ -1128,7 +1139,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -1128,7 +1139,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Checks that deleting a password from the list view works. // Checks that deleting a password from the list view works.
...@@ -1179,7 +1191,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -1179,7 +1191,8 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
TapDone(); [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
@end @end
...@@ -290,16 +290,6 @@ bool IsCertificateCleared() { ...@@ -290,16 +290,6 @@ bool IsCertificateCleared() {
performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)]; performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];
} }
// Exits Settings by clicking on the Done button.
- (void)dismissSettings {
// Dismiss the settings.
[[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
// Wait for UI components to finish loading.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
// From the NTP, clears the cookies and site data via the UI. // From the NTP, clears the cookies and site data via the UI.
- (void)clearCookiesAndSiteData { - (void)clearCookiesAndSiteData {
[ChromeEarlGreyUI openSettingsMenu]; [ChromeEarlGreyUI openSettingsMenu];
...@@ -316,7 +306,8 @@ bool IsCertificateCleared() { ...@@ -316,7 +306,8 @@ bool IsCertificateCleared() {
performAction:grey_tap()]; performAction:grey_tap()];
[self clearBrowsingData]; [self clearBrowsingData];
[self dismissSettings]; [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// From the NTP, clears the saved passwords via the UI. // From the NTP, clears the saved passwords via the UI.
...@@ -350,7 +341,8 @@ bool IsCertificateCleared() { ...@@ -350,7 +341,8 @@ bool IsCertificateCleared() {
[[EarlGrey selectElementWithMatcher:ClearSavedPasswordsButton()] [[EarlGrey selectElementWithMatcher:ClearSavedPasswordsButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[self dismissSettings]; [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
} }
// Enable password management. // Enable password management.
......
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