Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: ios/chrome/browser/ui/settings/settings_egtest.mm

Issue 2642193012: Make EarlGrey matchers compliant with Chromium style. (Closed)
Patch Set: mistake Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/settings/settings_egtest.mm
diff --git a/ios/chrome/browser/ui/settings/settings_egtest.mm b/ios/chrome/browser/ui/settings/settings_egtest.mm
index 55ccaafdbda0860be2166b7eb5e279fc4b320e56..fcbd7394788b06ffb870ab89fe3a30d02431b712 100644
--- a/ios/chrome/browser/ui/settings/settings_egtest.mm
+++ b/ios/chrome/browser/ui/settings/settings_egtest.mm
@@ -48,7 +48,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
-using chrome_test_util::buttonWithAccessibilityLabelId;
+using chrome_test_util::ButtonWithAccessibilityLabelId;
namespace {
@@ -75,72 +75,72 @@ enum MetricsServiceType {
};
// Matcher for the clear browsing history cell on the clear browsing data panel.
-id<GREYMatcher> clearBrowsingHistoryButton() {
+id<GREYMatcher> ClearBrowsingHistoryButton() {
return grey_allOf(grey_accessibilityID(kClearBrowsingHistoryCellId),
grey_sufficientlyVisible(), nil);
}
// Matcher for the clear cookies cell on the clear browsing data panel.
-id<GREYMatcher> clearCookiesButton() {
+id<GREYMatcher> ClearCookiesButton() {
return grey_accessibilityID(kClearCookiesCellId);
}
// Matcher for the clear cache cell on the clear browsing data panel.
-id<GREYMatcher> clearCacheButton() {
+id<GREYMatcher> ClearCacheButton() {
return grey_allOf(grey_accessibilityID(kClearCacheCellId),
grey_sufficientlyVisible(), nil);
}
// Matcher for the clear saved passwords cell on the clear browsing data panel.
-id<GREYMatcher> clearSavedPasswordsButton() {
+id<GREYMatcher> ClearSavedPasswordsButton() {
return grey_allOf(grey_accessibilityID(kClearSavedPasswordsCellId),
grey_sufficientlyVisible(), nil);
}
// Matcher for the clear browsing data button on the clear browsing data panel.
-id<GREYMatcher> clearBrowsingDataButton() {
- return buttonWithAccessibilityLabelId(IDS_IOS_CLEAR_BUTTON);
+id<GREYMatcher> ClearBrowsingDataButton() {
+ return ButtonWithAccessibilityLabelId(IDS_IOS_CLEAR_BUTTON);
}
// Matcher for the done button in the navigation bar.
-id<GREYMatcher> navigationDoneButton() {
- return buttonWithAccessibilityLabelId(IDS_IOS_NAVIGATION_BAR_DONE_BUTTON);
+id<GREYMatcher> NavigationDoneButton() {
+ return ButtonWithAccessibilityLabelId(IDS_IOS_NAVIGATION_BAR_DONE_BUTTON);
}
// Matcher for the Settings button in the tools menu.
-id<GREYMatcher> settingsButton() {
+id<GREYMatcher> SettingsButton() {
return grey_accessibilityID(kToolsMenuSettingsId);
}
// Matcher for the Save Passwords cell on the main Settings screen.
-id<GREYMatcher> passwordsButton() {
- return buttonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS);
+id<GREYMatcher> PasswordsButton() {
+ return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS);
}
// Matcher for the Privacy cell on the main Settings screen.
-id<GREYMatcher> privacyButton() {
- return buttonWithAccessibilityLabelId(
+id<GREYMatcher> PrivacyButton() {
+ return ButtonWithAccessibilityLabelId(
IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY);
}
// Matcher for the Clear Browsing Data cell on the Privacy screen.
-id<GREYMatcher> clearBrowsingDataCell() {
- return buttonWithAccessibilityLabelId(IDS_IOS_CLEAR_BROWSING_DATA_TITLE);
+id<GREYMatcher> ClearBrowsingDataCell() {
+ return ButtonWithAccessibilityLabelId(IDS_IOS_CLEAR_BROWSING_DATA_TITLE);
}
// Matcher for the Search Engine cell on the main Settings screen.
-id<GREYMatcher> searchEngineButton() {
- return buttonWithAccessibilityLabelId(IDS_IOS_SEARCH_ENGINE_SETTING_TITLE);
+id<GREYMatcher> SearchEngineButton() {
+ return ButtonWithAccessibilityLabelId(IDS_IOS_SEARCH_ENGINE_SETTING_TITLE);
}
// Matcher for the Autofill Forms cell on the main Settings screen.
-id<GREYMatcher> autofillButton() {
- return buttonWithAccessibilityLabelId(IDS_IOS_AUTOFILL);
+id<GREYMatcher> AutofillButton() {
+ return ButtonWithAccessibilityLabelId(IDS_IOS_AUTOFILL);
}
// Matcher for the Google Apps cell on the main Settings screen.
-id<GREYMatcher> googleAppsButton() {
- return buttonWithAccessibilityLabelId(IDS_IOS_GOOGLE_APPS_SM_SETTINGS);
+id<GREYMatcher> GoogleAppsButton() {
+ return ButtonWithAccessibilityLabelId(IDS_IOS_GOOGLE_APPS_SM_SETTINGS);
}
// Matcher for the Google Chrome cell on the main Settings screen.
-id<GREYMatcher> googleChromeButton() {
- return buttonWithAccessibilityLabelId(IDS_IOS_PRODUCT_NAME);
+id<GREYMatcher> GoogleChromeButton() {
+ return ButtonWithAccessibilityLabelId(IDS_IOS_PRODUCT_NAME);
}
// Matcher for the Google Chrome cell on the main Settings screen.
-id<GREYMatcher> voiceSearchButton() {
+id<GREYMatcher> VoiceSearchButton() {
return grey_allOf(grey_accessibilityID(kSettingsVoiceSearchCellId),
grey_accessibilityTrait(UIAccessibilityTraitButton), nil);
}
@@ -150,7 +150,7 @@ void AssertNoCookieExists() {
NSError* error = nil;
chrome_test_util::ExecuteJavaScript(
base::SysUTF8ToNSString(kJavaScriptGetCookies), &error);
- [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText(
+ [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
kNoCookieText)]
assertWithMatcher:grey_notNil()];
}
@@ -163,7 +163,7 @@ void AssertCookieExists(const char cookie[]) {
NSString* const expectedCookieText =
[NSString stringWithFormat:@"OK: %@", base::SysUTF8ToNSString(cookie)];
[[EarlGrey
- selectElementWithMatcher:chrome_test_util::webViewContainingText(
+ selectElementWithMatcher:chrome_test_util::WebViewContainingText(
base::SysNSStringToUTF8(expectedCookieText))]
assertWithMatcher:grey_notNil()];
}
@@ -282,7 +282,7 @@ bool IsCertificateCleared() {
UIAccessibilityTraitButton),
nil)] performAction:grey_tap()];
[[EarlGrey
- selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabelId(
+ selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)]
performAction:grey_tap()];
}
@@ -291,7 +291,7 @@ bool IsCertificateCleared() {
// Clear Browsing Data settings screen, after having selected the data types
// scheduled for removal.
- (void)clearBrowsingData {
- [[EarlGrey selectElementWithMatcher:clearBrowsingDataButton()]
+ [[EarlGrey selectElementWithMatcher:ClearBrowsingDataButton()]
performAction:grey_tap()];
// There is not currently a matcher for accessibilityElementIsFocused or
@@ -299,7 +299,7 @@ bool IsCertificateCleared() {
// the button is not a MDCCollectionViewTextCell. Use when available.
// TODO(crbug.com/638674): Evaluate if this can move to shared code.
id<GREYMatcher> confirmClear = grey_allOf(
- clearBrowsingDataButton(),
+ ClearBrowsingDataButton(),
grey_not(grey_kindOfClass([MDCCollectionViewTextCell class])), nil);
[[EarlGrey selectElementWithMatcher:confirmClear] performAction:grey_tap()];
}
@@ -307,7 +307,7 @@ bool IsCertificateCleared() {
// Exits Settings by clicking on the Done button.
- (void)dismissSettings {
// Dismiss the settings.
- [[EarlGrey selectElementWithMatcher:navigationDoneButton()]
+ [[EarlGrey selectElementWithMatcher:NavigationDoneButton()]
performAction:grey_tap()];
// Wait for UI components to finish loading.
@@ -317,20 +317,20 @@ bool IsCertificateCleared() {
// From the NTP, clears the cookies and site data via the UI.
- (void)clearCookiesAndSiteData {
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:privacyButton()]
+ [[EarlGrey selectElementWithMatcher:PrivacyButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:clearBrowsingDataCell()]
+ [[EarlGrey selectElementWithMatcher:ClearBrowsingDataCell()]
performAction:grey_tap()];
// "Browsing history", "Cookies, Site Data" and "Cached Images and Files"
// are the default checked options when the prefs are registered. Uncheck
// "Browsing history" and "Cached Images and Files".
// Prefs are reset to default at the end of each test.
- [[EarlGrey selectElementWithMatcher:clearBrowsingHistoryButton()]
+ [[EarlGrey selectElementWithMatcher:ClearBrowsingHistoryButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:clearCacheButton()]
+ [[EarlGrey selectElementWithMatcher:ClearCacheButton()]
performAction:grey_tap()];
[self clearBrowsingData];
@@ -340,36 +340,36 @@ bool IsCertificateCleared() {
// From the NTP, clears the saved passwords via the UI.
- (void)clearPasswords {
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:privacyButton()]
+ [[EarlGrey selectElementWithMatcher:PrivacyButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:clearBrowsingDataCell()]
+ [[EarlGrey selectElementWithMatcher:ClearBrowsingDataCell()]
performAction:grey_tap()];
// "Browsing history", "Cookies, Site Data" and "Cached Images and Files"
// are the default checked options when the prefs are registered. Unckeck all
// of them and check "Passwords".
- [[EarlGrey selectElementWithMatcher:clearBrowsingHistoryButton()]
+ [[EarlGrey selectElementWithMatcher:ClearBrowsingHistoryButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:clearCookiesButton()]
+ [[EarlGrey selectElementWithMatcher:ClearCookiesButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:clearCacheButton()]
+ [[EarlGrey selectElementWithMatcher:ClearCacheButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:clearSavedPasswordsButton()]
+ [[EarlGrey selectElementWithMatcher:ClearSavedPasswordsButton()]
performAction:grey_tap()];
[self clearBrowsingData];
// Re-tap all the previously tapped cells, so that the default state of the
// checkmarks is preserved.
- [[EarlGrey selectElementWithMatcher:clearBrowsingHistoryButton()]
+ [[EarlGrey selectElementWithMatcher:ClearBrowsingHistoryButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:clearCookiesButton()]
+ [[EarlGrey selectElementWithMatcher:ClearCookiesButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:clearCacheButton()]
+ [[EarlGrey selectElementWithMatcher:ClearCacheButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:clearSavedPasswordsButton()]
+ [[EarlGrey selectElementWithMatcher:ClearSavedPasswordsButton()]
performAction:grey_tap()];
[self dismissSettings];
@@ -380,9 +380,9 @@ bool IsCertificateCleared() {
// If |saved| is NO, it checks that there is no Saved Passwords section.
- (void)checkIfPasswordsSaved:(BOOL)saved {
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:passwordsButton()]
+ [[EarlGrey selectElementWithMatcher:PasswordsButton()]
performAction:grey_tap()];
id<GREYMatcher> visibilityMatcher =
@@ -588,7 +588,7 @@ bool IsCertificateCleared() {
// Load |kUrl| and check that cookie is not set.
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)];
- [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText(
+ [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
kResponse)]
assertWithMatcher:grey_notNil()];
AssertNoCookieExists();
@@ -596,11 +596,11 @@ bool IsCertificateCleared() {
// Visit |kUrlWithSetCookie| to set a cookie and then load |kUrl| to check it
// is still set.
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrlWithSetCookie)];
- [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText(
+ [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
kResponseWithSetCookie)]
assertWithMatcher:grey_notNil()];
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)];
- [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText(
+ [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
kResponse)]
assertWithMatcher:grey_notNil()];
@@ -625,7 +625,7 @@ bool IsCertificateCleared() {
// Reload and test that there are no cookies left.
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)];
- [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText(
+ [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
kResponse)]
assertWithMatcher:grey_notNil()];
AssertNoCookieExists();
@@ -683,7 +683,7 @@ bool IsCertificateCleared() {
// Login to page and click to save password and check that its saved.
[ChromeEarlGrey loadURL:URL];
chrome_test_util::TapWebViewElementWithId("Login");
- [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabelId(
+ [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId(
IDS_IOS_PASSWORD_MANAGER_SAVE_BUTTON)]
performAction:grey_tap()];
@@ -759,13 +759,13 @@ bool IsCertificateCleared() {
chrome_test_util::OpenNewIncognitoTab();
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)]
assertWithMatcher:grey_notNil()];
- [[EarlGrey selectElementWithMatcher:navigationDoneButton()]
+ [[EarlGrey selectElementWithMatcher:NavigationDoneButton()]
performAction:grey_tap()];
chrome_test_util::CloseAllIncognitoTabs();
}
@@ -773,18 +773,18 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessibile on the Settings page.
- (void)testAccessibilityOnSettingsPage {
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[[EarlGrey
- selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabelId(
+ selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)]
performAction:grey_tap()];
}
// Verifies the UI elements are accessibile on the Content Settings page.
- (void)testAccessibilityOnContentSettingsPage {
- [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId(
+ [self openSubSettingMenu:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_CONTENT_SETTINGS_TITLE)];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
@@ -792,7 +792,7 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessibile on the Privacy Settings page.
- (void)testAccessibilityOnPrivacySettingsPage {
- [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId(
+ [self openSubSettingMenu:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
@@ -801,7 +801,7 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessibile on the Bandwidth Management Settings
// page.
- (void)testAccessibilityOnBandwidthManagementSettingsPage {
- [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId(
+ [self openSubSettingMenu:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_BANDWIDTH_MANAGEMENT_SETTINGS)];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
@@ -810,9 +810,9 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessible on the Save Passwords page.
- (void)testAccessibilityOnSavePasswords {
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:passwordsButton()]
+ [[EarlGrey selectElementWithMatcher:PasswordsButton()]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
@@ -821,9 +821,9 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessible on the Search engine page.
- (void)testAccessibilityOnSearchEngine {
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:searchEngineButton()]
+ [[EarlGrey selectElementWithMatcher:SearchEngineButton()]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
@@ -832,9 +832,9 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessible on the Autofill Forms page.
- (void)testAccessibilityOnAutofillForms {
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:autofillButton()]
+ [[EarlGrey selectElementWithMatcher:AutofillButton()]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
@@ -843,9 +843,9 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessible on the Google Apps page.
- (void)testAccessibilityOnGoogleApps {
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:googleAppsButton()]
+ [[EarlGrey selectElementWithMatcher:GoogleAppsButton()]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
@@ -853,14 +853,14 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessible on the About Chrome page.
- (void)testAccessibilityOnGoogleChrome {
- [self openSubSettingMenu:googleChromeButton()];
+ [self openSubSettingMenu:GoogleChromeButton()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
}
// Verifies the UI elements are accessible on the Voice Search page.
- (void)testAccessibilityOnVoiceSearch {
- [self openSubSettingMenu:voiceSearchButton()];
+ [self openSubSettingMenu:VoiceSearchButton()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
}
@@ -868,9 +868,9 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessible on the Passwords page.
- (void)testAccessibilityOnPasswords {
[ChromeEarlGreyUI openToolsMenu];
- [[EarlGrey selectElementWithMatcher:settingsButton()]
+ [[EarlGrey selectElementWithMatcher:SettingsButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:passwordsButton()]
+ [[EarlGrey selectElementWithMatcher:PasswordsButton()]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];

Powered by Google App Engine
This is Rietveld 408576698