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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <EarlGrey/EarlGrey.h> 5 #import <EarlGrey/EarlGrey.h>
6 #import <UIKit/UIKit.h> 6 #import <UIKit/UIKit.h>
7 #import <XCTest/XCTest.h> 7 #import <XCTest/XCTest.h>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 30 matching lines...) Expand all
41 #import "ios/web/public/test/web_view_interaction_test_util.h" 41 #import "ios/web/public/test/web_view_interaction_test_util.h"
42 #import "ios/web/public/web_state/web_state.h" 42 #import "ios/web/public/web_state/web_state.h"
43 #include "ios/web/public/web_thread.h" 43 #include "ios/web/public/web_thread.h"
44 #include "net/ssl/channel_id_service.h" 44 #include "net/ssl/channel_id_service.h"
45 #include "net/ssl/channel_id_store.h" 45 #include "net/ssl/channel_id_store.h"
46 #include "net/url_request/url_request_context.h" 46 #include "net/url_request/url_request_context.h"
47 #include "net/url_request/url_request_context_getter.h" 47 #include "net/url_request/url_request_context_getter.h"
48 #include "ui/base/l10n/l10n_util.h" 48 #include "ui/base/l10n/l10n_util.h"
49 #include "url/gurl.h" 49 #include "url/gurl.h"
50 50
51 using chrome_test_util::buttonWithAccessibilityLabelId; 51 using chrome_test_util::ButtonWithAccessibilityLabelId;
52 52
53 namespace { 53 namespace {
54 54
55 const char kTestOrigin1[] = "http://host1:1/"; 55 const char kTestOrigin1[] = "http://host1:1/";
56 56
57 const char kUrl[] = "http://foo/browsing"; 57 const char kUrl[] = "http://foo/browsing";
58 const char kUrlWithSetCookie[] = "http://foo/set_cookie"; 58 const char kUrlWithSetCookie[] = "http://foo/set_cookie";
59 const char kResponse[] = "bar"; 59 const char kResponse[] = "bar";
60 const char kResponseWithSetCookie[] = "bar with set cookie"; 60 const char kResponseWithSetCookie[] = "bar with set cookie";
61 const char kNoCookieText[] = "No cookies"; 61 const char kNoCookieText[] = "No cookies";
62 const char kCookie[] = "a=b"; 62 const char kCookie[] = "a=b";
63 const char kJavaScriptGetCookies[] = 63 const char kJavaScriptGetCookies[] =
64 "var c = document.cookie ? document.cookie.split(/;\\s*/) : [];" 64 "var c = document.cookie ? document.cookie.split(/;\\s*/) : [];"
65 "if (!c.length) {" 65 "if (!c.length) {"
66 " document.documentElement.innerHTML = 'No cookies!';" 66 " document.documentElement.innerHTML = 'No cookies!';"
67 "} else {" 67 "} else {"
68 " document.documentElement.innerHTML = 'OK: ' + c.join(',');" 68 " document.documentElement.innerHTML = 'OK: ' + c.join(',');"
69 "}"; 69 "}";
70 70
71 enum MetricsServiceType { 71 enum MetricsServiceType {
72 kMetrics, 72 kMetrics,
73 kBreakpad, 73 kBreakpad,
74 kBreakpadFirstLaunch, 74 kBreakpadFirstLaunch,
75 }; 75 };
76 76
77 // Matcher for the clear browsing history cell on the clear browsing data panel. 77 // Matcher for the clear browsing history cell on the clear browsing data panel.
78 id<GREYMatcher> clearBrowsingHistoryButton() { 78 id<GREYMatcher> ClearBrowsingHistoryButton() {
79 return grey_allOf(grey_accessibilityID(kClearBrowsingHistoryCellId), 79 return grey_allOf(grey_accessibilityID(kClearBrowsingHistoryCellId),
80 grey_sufficientlyVisible(), nil); 80 grey_sufficientlyVisible(), nil);
81 } 81 }
82 // Matcher for the clear cookies cell on the clear browsing data panel. 82 // Matcher for the clear cookies cell on the clear browsing data panel.
83 id<GREYMatcher> clearCookiesButton() { 83 id<GREYMatcher> ClearCookiesButton() {
84 return grey_accessibilityID(kClearCookiesCellId); 84 return grey_accessibilityID(kClearCookiesCellId);
85 } 85 }
86 // Matcher for the clear cache cell on the clear browsing data panel. 86 // Matcher for the clear cache cell on the clear browsing data panel.
87 id<GREYMatcher> clearCacheButton() { 87 id<GREYMatcher> ClearCacheButton() {
88 return grey_allOf(grey_accessibilityID(kClearCacheCellId), 88 return grey_allOf(grey_accessibilityID(kClearCacheCellId),
89 grey_sufficientlyVisible(), nil); 89 grey_sufficientlyVisible(), nil);
90 } 90 }
91 // Matcher for the clear saved passwords cell on the clear browsing data panel. 91 // Matcher for the clear saved passwords cell on the clear browsing data panel.
92 id<GREYMatcher> clearSavedPasswordsButton() { 92 id<GREYMatcher> ClearSavedPasswordsButton() {
93 return grey_allOf(grey_accessibilityID(kClearSavedPasswordsCellId), 93 return grey_allOf(grey_accessibilityID(kClearSavedPasswordsCellId),
94 grey_sufficientlyVisible(), nil); 94 grey_sufficientlyVisible(), nil);
95 } 95 }
96 // Matcher for the clear browsing data button on the clear browsing data panel. 96 // Matcher for the clear browsing data button on the clear browsing data panel.
97 id<GREYMatcher> clearBrowsingDataButton() { 97 id<GREYMatcher> ClearBrowsingDataButton() {
98 return buttonWithAccessibilityLabelId(IDS_IOS_CLEAR_BUTTON); 98 return ButtonWithAccessibilityLabelId(IDS_IOS_CLEAR_BUTTON);
99 } 99 }
100 // Matcher for the done button in the navigation bar. 100 // Matcher for the done button in the navigation bar.
101 id<GREYMatcher> navigationDoneButton() { 101 id<GREYMatcher> NavigationDoneButton() {
102 return buttonWithAccessibilityLabelId(IDS_IOS_NAVIGATION_BAR_DONE_BUTTON); 102 return ButtonWithAccessibilityLabelId(IDS_IOS_NAVIGATION_BAR_DONE_BUTTON);
103 } 103 }
104 // Matcher for the Settings button in the tools menu. 104 // Matcher for the Settings button in the tools menu.
105 id<GREYMatcher> settingsButton() { 105 id<GREYMatcher> SettingsButton() {
106 return grey_accessibilityID(kToolsMenuSettingsId); 106 return grey_accessibilityID(kToolsMenuSettingsId);
107 } 107 }
108 // Matcher for the Save Passwords cell on the main Settings screen. 108 // Matcher for the Save Passwords cell on the main Settings screen.
109 id<GREYMatcher> passwordsButton() { 109 id<GREYMatcher> PasswordsButton() {
110 return buttonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS); 110 return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS);
111 } 111 }
112 // Matcher for the Privacy cell on the main Settings screen. 112 // Matcher for the Privacy cell on the main Settings screen.
113 id<GREYMatcher> privacyButton() { 113 id<GREYMatcher> PrivacyButton() {
114 return buttonWithAccessibilityLabelId( 114 return ButtonWithAccessibilityLabelId(
115 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY); 115 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY);
116 } 116 }
117 // Matcher for the Clear Browsing Data cell on the Privacy screen. 117 // Matcher for the Clear Browsing Data cell on the Privacy screen.
118 id<GREYMatcher> clearBrowsingDataCell() { 118 id<GREYMatcher> ClearBrowsingDataCell() {
119 return buttonWithAccessibilityLabelId(IDS_IOS_CLEAR_BROWSING_DATA_TITLE); 119 return ButtonWithAccessibilityLabelId(IDS_IOS_CLEAR_BROWSING_DATA_TITLE);
120 } 120 }
121 121
122 // Matcher for the Search Engine cell on the main Settings screen. 122 // Matcher for the Search Engine cell on the main Settings screen.
123 id<GREYMatcher> searchEngineButton() { 123 id<GREYMatcher> SearchEngineButton() {
124 return buttonWithAccessibilityLabelId(IDS_IOS_SEARCH_ENGINE_SETTING_TITLE); 124 return ButtonWithAccessibilityLabelId(IDS_IOS_SEARCH_ENGINE_SETTING_TITLE);
125 } 125 }
126 126
127 // Matcher for the Autofill Forms cell on the main Settings screen. 127 // Matcher for the Autofill Forms cell on the main Settings screen.
128 id<GREYMatcher> autofillButton() { 128 id<GREYMatcher> AutofillButton() {
129 return buttonWithAccessibilityLabelId(IDS_IOS_AUTOFILL); 129 return ButtonWithAccessibilityLabelId(IDS_IOS_AUTOFILL);
130 } 130 }
131 131
132 // Matcher for the Google Apps cell on the main Settings screen. 132 // Matcher for the Google Apps cell on the main Settings screen.
133 id<GREYMatcher> googleAppsButton() { 133 id<GREYMatcher> GoogleAppsButton() {
134 return buttonWithAccessibilityLabelId(IDS_IOS_GOOGLE_APPS_SM_SETTINGS); 134 return ButtonWithAccessibilityLabelId(IDS_IOS_GOOGLE_APPS_SM_SETTINGS);
135 } 135 }
136 136
137 // Matcher for the Google Chrome cell on the main Settings screen. 137 // Matcher for the Google Chrome cell on the main Settings screen.
138 id<GREYMatcher> googleChromeButton() { 138 id<GREYMatcher> GoogleChromeButton() {
139 return buttonWithAccessibilityLabelId(IDS_IOS_PRODUCT_NAME); 139 return ButtonWithAccessibilityLabelId(IDS_IOS_PRODUCT_NAME);
140 } 140 }
141 141
142 // Matcher for the Google Chrome cell on the main Settings screen. 142 // Matcher for the Google Chrome cell on the main Settings screen.
143 id<GREYMatcher> voiceSearchButton() { 143 id<GREYMatcher> VoiceSearchButton() {
144 return grey_allOf(grey_accessibilityID(kSettingsVoiceSearchCellId), 144 return grey_allOf(grey_accessibilityID(kSettingsVoiceSearchCellId),
145 grey_accessibilityTrait(UIAccessibilityTraitButton), nil); 145 grey_accessibilityTrait(UIAccessibilityTraitButton), nil);
146 } 146 }
147 147
148 // Asserts that there is no cookie in current web state. 148 // Asserts that there is no cookie in current web state.
149 void AssertNoCookieExists() { 149 void AssertNoCookieExists() {
150 NSError* error = nil; 150 NSError* error = nil;
151 chrome_test_util::ExecuteJavaScript( 151 chrome_test_util::ExecuteJavaScript(
152 base::SysUTF8ToNSString(kJavaScriptGetCookies), &error); 152 base::SysUTF8ToNSString(kJavaScriptGetCookies), &error);
153 [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText( 153 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
154 kNoCookieText)] 154 kNoCookieText)]
155 assertWithMatcher:grey_notNil()]; 155 assertWithMatcher:grey_notNil()];
156 } 156 }
157 157
158 // Asserts |cookie| exists in current web state. 158 // Asserts |cookie| exists in current web state.
159 void AssertCookieExists(const char cookie[]) { 159 void AssertCookieExists(const char cookie[]) {
160 NSError* error = nil; 160 NSError* error = nil;
161 chrome_test_util::ExecuteJavaScript( 161 chrome_test_util::ExecuteJavaScript(
162 base::SysUTF8ToNSString(kJavaScriptGetCookies), &error); 162 base::SysUTF8ToNSString(kJavaScriptGetCookies), &error);
163 NSString* const expectedCookieText = 163 NSString* const expectedCookieText =
164 [NSString stringWithFormat:@"OK: %@", base::SysUTF8ToNSString(cookie)]; 164 [NSString stringWithFormat:@"OK: %@", base::SysUTF8ToNSString(cookie)];
165 [[EarlGrey 165 [[EarlGrey
166 selectElementWithMatcher:chrome_test_util::webViewContainingText( 166 selectElementWithMatcher:chrome_test_util::WebViewContainingText(
167 base::SysNSStringToUTF8(expectedCookieText))] 167 base::SysNSStringToUTF8(expectedCookieText))]
168 assertWithMatcher:grey_notNil()]; 168 assertWithMatcher:grey_notNil()];
169 } 169 }
170 170
171 // Run as a task to check if a certificate has been added to the ChannelIDStore. 171 // Run as a task to check if a certificate has been added to the ChannelIDStore.
172 // Signals the given |semaphore| if the cert was added, or reposts itself 172 // Signals the given |semaphore| if the cert was added, or reposts itself
173 // otherwise. 173 // otherwise.
174 void CheckCertificate(scoped_refptr<net::URLRequestContextGetter> getter, 174 void CheckCertificate(scoped_refptr<net::URLRequestContextGetter> getter,
175 dispatch_semaphore_t semaphore) { 175 dispatch_semaphore_t semaphore) {
176 net::ChannelIDService* channel_id_service = 176 net::ChannelIDService* channel_id_service =
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 // Closes a sub-settings menu, and then the general Settings menu. 276 // Closes a sub-settings menu, and then the general Settings menu.
277 - (void)closeSubSettingsMenu { 277 - (void)closeSubSettingsMenu {
278 [[EarlGrey 278 [[EarlGrey
279 selectElementWithMatcher:grey_allOf( 279 selectElementWithMatcher:grey_allOf(
280 grey_accessibilityID(@"ic_arrow_back"), 280 grey_accessibilityID(@"ic_arrow_back"),
281 grey_accessibilityTrait( 281 grey_accessibilityTrait(
282 UIAccessibilityTraitButton), 282 UIAccessibilityTraitButton),
283 nil)] performAction:grey_tap()]; 283 nil)] performAction:grey_tap()];
284 [[EarlGrey 284 [[EarlGrey
285 selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabelId( 285 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
286 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] 286 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)]
287 performAction:grey_tap()]; 287 performAction:grey_tap()];
288 } 288 }
289 289
290 // Performs the steps to clear browsing data. Must be called on the 290 // Performs the steps to clear browsing data. Must be called on the
291 // Clear Browsing Data settings screen, after having selected the data types 291 // Clear Browsing Data settings screen, after having selected the data types
292 // scheduled for removal. 292 // scheduled for removal.
293 - (void)clearBrowsingData { 293 - (void)clearBrowsingData {
294 [[EarlGrey selectElementWithMatcher:clearBrowsingDataButton()] 294 [[EarlGrey selectElementWithMatcher:ClearBrowsingDataButton()]
295 performAction:grey_tap()]; 295 performAction:grey_tap()];
296 296
297 // There is not currently a matcher for accessibilityElementIsFocused or 297 // There is not currently a matcher for accessibilityElementIsFocused or
298 // userInteractionEnabled which could be used here instead of checking that 298 // userInteractionEnabled which could be used here instead of checking that
299 // the button is not a MDCCollectionViewTextCell. Use when available. 299 // the button is not a MDCCollectionViewTextCell. Use when available.
300 // TODO(crbug.com/638674): Evaluate if this can move to shared code. 300 // TODO(crbug.com/638674): Evaluate if this can move to shared code.
301 id<GREYMatcher> confirmClear = grey_allOf( 301 id<GREYMatcher> confirmClear = grey_allOf(
302 clearBrowsingDataButton(), 302 ClearBrowsingDataButton(),
303 grey_not(grey_kindOfClass([MDCCollectionViewTextCell class])), nil); 303 grey_not(grey_kindOfClass([MDCCollectionViewTextCell class])), nil);
304 [[EarlGrey selectElementWithMatcher:confirmClear] performAction:grey_tap()]; 304 [[EarlGrey selectElementWithMatcher:confirmClear] performAction:grey_tap()];
305 } 305 }
306 306
307 // Exits Settings by clicking on the Done button. 307 // Exits Settings by clicking on the Done button.
308 - (void)dismissSettings { 308 - (void)dismissSettings {
309 // Dismiss the settings. 309 // Dismiss the settings.
310 [[EarlGrey selectElementWithMatcher:navigationDoneButton()] 310 [[EarlGrey selectElementWithMatcher:NavigationDoneButton()]
311 performAction:grey_tap()]; 311 performAction:grey_tap()];
312 312
313 // Wait for UI components to finish loading. 313 // Wait for UI components to finish loading.
314 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; 314 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
315 } 315 }
316 316
317 // From the NTP, clears the cookies and site data via the UI. 317 // From the NTP, clears the cookies and site data via the UI.
318 - (void)clearCookiesAndSiteData { 318 - (void)clearCookiesAndSiteData {
319 [ChromeEarlGreyUI openToolsMenu]; 319 [ChromeEarlGreyUI openToolsMenu];
320 [[EarlGrey selectElementWithMatcher:settingsButton()] 320 [[EarlGrey selectElementWithMatcher:SettingsButton()]
321 performAction:grey_tap()]; 321 performAction:grey_tap()];
322 [[EarlGrey selectElementWithMatcher:privacyButton()] 322 [[EarlGrey selectElementWithMatcher:PrivacyButton()]
323 performAction:grey_tap()]; 323 performAction:grey_tap()];
324 [[EarlGrey selectElementWithMatcher:clearBrowsingDataCell()] 324 [[EarlGrey selectElementWithMatcher:ClearBrowsingDataCell()]
325 performAction:grey_tap()]; 325 performAction:grey_tap()];
326 326
327 // "Browsing history", "Cookies, Site Data" and "Cached Images and Files" 327 // "Browsing history", "Cookies, Site Data" and "Cached Images and Files"
328 // are the default checked options when the prefs are registered. Uncheck 328 // are the default checked options when the prefs are registered. Uncheck
329 // "Browsing history" and "Cached Images and Files". 329 // "Browsing history" and "Cached Images and Files".
330 // Prefs are reset to default at the end of each test. 330 // Prefs are reset to default at the end of each test.
331 [[EarlGrey selectElementWithMatcher:clearBrowsingHistoryButton()] 331 [[EarlGrey selectElementWithMatcher:ClearBrowsingHistoryButton()]
332 performAction:grey_tap()]; 332 performAction:grey_tap()];
333 [[EarlGrey selectElementWithMatcher:clearCacheButton()] 333 [[EarlGrey selectElementWithMatcher:ClearCacheButton()]
334 performAction:grey_tap()]; 334 performAction:grey_tap()];
335 335
336 [self clearBrowsingData]; 336 [self clearBrowsingData];
337 [self dismissSettings]; 337 [self dismissSettings];
338 } 338 }
339 339
340 // From the NTP, clears the saved passwords via the UI. 340 // From the NTP, clears the saved passwords via the UI.
341 - (void)clearPasswords { 341 - (void)clearPasswords {
342 [ChromeEarlGreyUI openToolsMenu]; 342 [ChromeEarlGreyUI openToolsMenu];
343 [[EarlGrey selectElementWithMatcher:settingsButton()] 343 [[EarlGrey selectElementWithMatcher:SettingsButton()]
344 performAction:grey_tap()]; 344 performAction:grey_tap()];
345 [[EarlGrey selectElementWithMatcher:privacyButton()] 345 [[EarlGrey selectElementWithMatcher:PrivacyButton()]
346 performAction:grey_tap()]; 346 performAction:grey_tap()];
347 [[EarlGrey selectElementWithMatcher:clearBrowsingDataCell()] 347 [[EarlGrey selectElementWithMatcher:ClearBrowsingDataCell()]
348 performAction:grey_tap()]; 348 performAction:grey_tap()];
349 349
350 // "Browsing history", "Cookies, Site Data" and "Cached Images and Files" 350 // "Browsing history", "Cookies, Site Data" and "Cached Images and Files"
351 // are the default checked options when the prefs are registered. Unckeck all 351 // are the default checked options when the prefs are registered. Unckeck all
352 // of them and check "Passwords". 352 // of them and check "Passwords".
353 [[EarlGrey selectElementWithMatcher:clearBrowsingHistoryButton()] 353 [[EarlGrey selectElementWithMatcher:ClearBrowsingHistoryButton()]
354 performAction:grey_tap()]; 354 performAction:grey_tap()];
355 [[EarlGrey selectElementWithMatcher:clearCookiesButton()] 355 [[EarlGrey selectElementWithMatcher:ClearCookiesButton()]
356 performAction:grey_tap()]; 356 performAction:grey_tap()];
357 [[EarlGrey selectElementWithMatcher:clearCacheButton()] 357 [[EarlGrey selectElementWithMatcher:ClearCacheButton()]
358 performAction:grey_tap()]; 358 performAction:grey_tap()];
359 [[EarlGrey selectElementWithMatcher:clearSavedPasswordsButton()] 359 [[EarlGrey selectElementWithMatcher:ClearSavedPasswordsButton()]
360 performAction:grey_tap()]; 360 performAction:grey_tap()];
361 361
362 [self clearBrowsingData]; 362 [self clearBrowsingData];
363 363
364 // Re-tap all the previously tapped cells, so that the default state of the 364 // Re-tap all the previously tapped cells, so that the default state of the
365 // checkmarks is preserved. 365 // checkmarks is preserved.
366 [[EarlGrey selectElementWithMatcher:clearBrowsingHistoryButton()] 366 [[EarlGrey selectElementWithMatcher:ClearBrowsingHistoryButton()]
367 performAction:grey_tap()]; 367 performAction:grey_tap()];
368 [[EarlGrey selectElementWithMatcher:clearCookiesButton()] 368 [[EarlGrey selectElementWithMatcher:ClearCookiesButton()]
369 performAction:grey_tap()]; 369 performAction:grey_tap()];
370 [[EarlGrey selectElementWithMatcher:clearCacheButton()] 370 [[EarlGrey selectElementWithMatcher:ClearCacheButton()]
371 performAction:grey_tap()]; 371 performAction:grey_tap()];
372 [[EarlGrey selectElementWithMatcher:clearSavedPasswordsButton()] 372 [[EarlGrey selectElementWithMatcher:ClearSavedPasswordsButton()]
373 performAction:grey_tap()]; 373 performAction:grey_tap()];
374 374
375 [self dismissSettings]; 375 [self dismissSettings];
376 } 376 }
377 377
378 // Checks the presence (or absence) of saved passwords. 378 // Checks the presence (or absence) of saved passwords.
379 // If |saved| is YES, it checks that there is a Saved Passwords section. 379 // If |saved| is YES, it checks that there is a Saved Passwords section.
380 // If |saved| is NO, it checks that there is no Saved Passwords section. 380 // If |saved| is NO, it checks that there is no Saved Passwords section.
381 - (void)checkIfPasswordsSaved:(BOOL)saved { 381 - (void)checkIfPasswordsSaved:(BOOL)saved {
382 [ChromeEarlGreyUI openToolsMenu]; 382 [ChromeEarlGreyUI openToolsMenu];
383 [[EarlGrey selectElementWithMatcher:settingsButton()] 383 [[EarlGrey selectElementWithMatcher:SettingsButton()]
384 performAction:grey_tap()]; 384 performAction:grey_tap()];
385 [[EarlGrey selectElementWithMatcher:passwordsButton()] 385 [[EarlGrey selectElementWithMatcher:PasswordsButton()]
386 performAction:grey_tap()]; 386 performAction:grey_tap()];
387 387
388 id<GREYMatcher> visibilityMatcher = 388 id<GREYMatcher> visibilityMatcher =
389 saved ? grey_sufficientlyVisible() : grey_notVisible(); 389 saved ? grey_sufficientlyVisible() : grey_notVisible();
390 [[EarlGrey selectElementWithMatcher: 390 [[EarlGrey selectElementWithMatcher:
391 grey_text(l10n_util::GetNSString( 391 grey_text(l10n_util::GetNSString(
392 IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE))] 392 IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE))]
393 assertWithMatcher:visibilityMatcher]; 393 assertWithMatcher:visibilityMatcher];
394 394
395 // Close the Settings. 395 // Close the Settings.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 581
582 response[web::test::HttpServer::MakeUrl(kUrlWithSetCookie)] = 582 response[web::test::HttpServer::MakeUrl(kUrlWithSetCookie)] =
583 std::pair<std::string, std::string>(kCookie, kResponseWithSetCookie); 583 std::pair<std::string, std::string>(kCookie, kResponseWithSetCookie);
584 response[web::test::HttpServer::MakeUrl(kUrl)] = 584 response[web::test::HttpServer::MakeUrl(kUrl)] =
585 std::pair<std::string, std::string>("", kResponse); 585 std::pair<std::string, std::string>("", kResponse);
586 586
587 web::test::SetUpSimpleHttpServerWithSetCookies(response); 587 web::test::SetUpSimpleHttpServerWithSetCookies(response);
588 588
589 // Load |kUrl| and check that cookie is not set. 589 // Load |kUrl| and check that cookie is not set.
590 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; 590 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)];
591 [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText( 591 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
592 kResponse)] 592 kResponse)]
593 assertWithMatcher:grey_notNil()]; 593 assertWithMatcher:grey_notNil()];
594 AssertNoCookieExists(); 594 AssertNoCookieExists();
595 595
596 // Visit |kUrlWithSetCookie| to set a cookie and then load |kUrl| to check it 596 // Visit |kUrlWithSetCookie| to set a cookie and then load |kUrl| to check it
597 // is still set. 597 // is still set.
598 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrlWithSetCookie)]; 598 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrlWithSetCookie)];
599 [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText( 599 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
600 kResponseWithSetCookie)] 600 kResponseWithSetCookie)]
601 assertWithMatcher:grey_notNil()]; 601 assertWithMatcher:grey_notNil()];
602 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; 602 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)];
603 [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText( 603 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
604 kResponse)] 604 kResponse)]
605 assertWithMatcher:grey_notNil()]; 605 assertWithMatcher:grey_notNil()];
606 606
607 AssertCookieExists(kCookie); 607 AssertCookieExists(kCookie);
608 608
609 // Restore the Clear Browsing Data checkmarks prefs to their default state in 609 // Restore the Clear Browsing Data checkmarks prefs to their default state in
610 // Teardown. 610 // Teardown.
611 [self setTearDownHandler:^{ 611 [self setTearDownHandler:^{
612 ios::ChromeBrowserState* browserState = 612 ios::ChromeBrowserState* browserState =
613 chrome_test_util::GetOriginalBrowserState(); 613 chrome_test_util::GetOriginalBrowserState();
614 PrefService* preferences = browserState->GetPrefs(); 614 PrefService* preferences = browserState->GetPrefs();
615 615
616 preferences->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, true); 616 preferences->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, true);
617 preferences->SetBoolean(browsing_data::prefs::kDeleteCache, true); 617 preferences->SetBoolean(browsing_data::prefs::kDeleteCache, true);
618 preferences->SetBoolean(browsing_data::prefs::kDeleteCookies, true); 618 preferences->SetBoolean(browsing_data::prefs::kDeleteCookies, true);
619 preferences->SetBoolean(browsing_data::prefs::kDeletePasswords, false); 619 preferences->SetBoolean(browsing_data::prefs::kDeletePasswords, false);
620 preferences->SetBoolean(browsing_data::prefs::kDeleteFormData, false); 620 preferences->SetBoolean(browsing_data::prefs::kDeleteFormData, false);
621 }]; 621 }];
622 622
623 // Clear all cookies. 623 // Clear all cookies.
624 [self clearCookiesAndSiteData]; 624 [self clearCookiesAndSiteData];
625 625
626 // Reload and test that there are no cookies left. 626 // Reload and test that there are no cookies left.
627 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; 627 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)];
628 [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText( 628 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
629 kResponse)] 629 kResponse)]
630 assertWithMatcher:grey_notNil()]; 630 assertWithMatcher:grey_notNil()];
631 AssertNoCookieExists(); 631 AssertNoCookieExists();
632 chrome_test_util::CloseAllTabs(); 632 chrome_test_util::CloseAllTabs();
633 } 633 }
634 634
635 // Verifies that logging into a form on a web page allows the user to save and 635 // Verifies that logging into a form on a web page allows the user to save and
636 // then clear a password. 636 // then clear a password.
637 - (void)testClearPasswords { 637 - (void)testClearPasswords {
638 std::map<GURL, std::string> responses; 638 std::map<GURL, std::string> responses;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 preferences->SetBoolean(browsing_data::prefs::kDeleteFormData, false); 676 preferences->SetBoolean(browsing_data::prefs::kDeleteFormData, false);
677 }]; 677 }];
678 678
679 // Clear passwords and check that none are saved. 679 // Clear passwords and check that none are saved.
680 [self clearPasswords]; 680 [self clearPasswords];
681 [self checkIfPasswordsSaved:NO]; 681 [self checkIfPasswordsSaved:NO];
682 682
683 // Login to page and click to save password and check that its saved. 683 // Login to page and click to save password and check that its saved.
684 [ChromeEarlGrey loadURL:URL]; 684 [ChromeEarlGrey loadURL:URL];
685 chrome_test_util::TapWebViewElementWithId("Login"); 685 chrome_test_util::TapWebViewElementWithId("Login");
686 [[EarlGrey selectElementWithMatcher:buttonWithAccessibilityLabelId( 686 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId(
687 IDS_IOS_PASSWORD_MANAGER_SAVE_BUTTON)] 687 IDS_IOS_PASSWORD_MANAGER_SAVE_BUTTON)]
688 performAction:grey_tap()]; 688 performAction:grey_tap()];
689 689
690 [self checkIfPasswordsSaved:YES]; 690 [self checkIfPasswordsSaved:YES];
691 691
692 // Clear passwords and check that none are saved. 692 // Clear passwords and check that none are saved.
693 [self clearPasswords]; 693 [self clearPasswords];
694 [self checkIfPasswordsSaved:NO]; 694 [self checkIfPasswordsSaved:NO];
695 } 695 }
696 696
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 GREYAssertTrue(IsCertificateCleared(), 752 GREYAssertTrue(IsCertificateCleared(),
753 @"Certificate is expected to be deleted."); 753 @"Certificate is expected to be deleted.");
754 } 754 }
755 755
756 // Verifies that Settings opens when signed-out and in Incognito mode. 756 // Verifies that Settings opens when signed-out and in Incognito mode.
757 // This tests that crbug.com/607335 has not regressed. 757 // This tests that crbug.com/607335 has not regressed.
758 - (void)testSettingsSignedOutIncognito { 758 - (void)testSettingsSignedOutIncognito {
759 chrome_test_util::OpenNewIncognitoTab(); 759 chrome_test_util::OpenNewIncognitoTab();
760 760
761 [ChromeEarlGreyUI openToolsMenu]; 761 [ChromeEarlGreyUI openToolsMenu];
762 [[EarlGrey selectElementWithMatcher:settingsButton()] 762 [[EarlGrey selectElementWithMatcher:SettingsButton()]
763 performAction:grey_tap()]; 763 performAction:grey_tap()];
764 [[EarlGrey 764 [[EarlGrey
765 selectElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)] 765 selectElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)]
766 assertWithMatcher:grey_notNil()]; 766 assertWithMatcher:grey_notNil()];
767 767
768 [[EarlGrey selectElementWithMatcher:navigationDoneButton()] 768 [[EarlGrey selectElementWithMatcher:NavigationDoneButton()]
769 performAction:grey_tap()]; 769 performAction:grey_tap()];
770 chrome_test_util::CloseAllIncognitoTabs(); 770 chrome_test_util::CloseAllIncognitoTabs();
771 } 771 }
772 772
773 // Verifies the UI elements are accessibile on the Settings page. 773 // Verifies the UI elements are accessibile on the Settings page.
774 - (void)testAccessibilityOnSettingsPage { 774 - (void)testAccessibilityOnSettingsPage {
775 [ChromeEarlGreyUI openToolsMenu]; 775 [ChromeEarlGreyUI openToolsMenu];
776 [[EarlGrey selectElementWithMatcher:settingsButton()] 776 [[EarlGrey selectElementWithMatcher:SettingsButton()]
777 performAction:grey_tap()]; 777 performAction:grey_tap()];
778 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 778 chrome_test_util::VerifyAccessibilityForCurrentScreen();
779 [[EarlGrey 779 [[EarlGrey
780 selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabelId( 780 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
781 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] 781 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)]
782 performAction:grey_tap()]; 782 performAction:grey_tap()];
783 } 783 }
784 784
785 // Verifies the UI elements are accessibile on the Content Settings page. 785 // Verifies the UI elements are accessibile on the Content Settings page.
786 - (void)testAccessibilityOnContentSettingsPage { 786 - (void)testAccessibilityOnContentSettingsPage {
787 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( 787 [self openSubSettingMenu:chrome_test_util::ButtonWithAccessibilityLabelId(
788 IDS_IOS_CONTENT_SETTINGS_TITLE)]; 788 IDS_IOS_CONTENT_SETTINGS_TITLE)];
789 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 789 chrome_test_util::VerifyAccessibilityForCurrentScreen();
790 [self closeSubSettingsMenu]; 790 [self closeSubSettingsMenu];
791 } 791 }
792 792
793 // Verifies the UI elements are accessibile on the Privacy Settings page. 793 // Verifies the UI elements are accessibile on the Privacy Settings page.
794 - (void)testAccessibilityOnPrivacySettingsPage { 794 - (void)testAccessibilityOnPrivacySettingsPage {
795 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( 795 [self openSubSettingMenu:chrome_test_util::ButtonWithAccessibilityLabelId(
796 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)]; 796 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)];
797 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 797 chrome_test_util::VerifyAccessibilityForCurrentScreen();
798 [self closeSubSettingsMenu]; 798 [self closeSubSettingsMenu];
799 } 799 }
800 800
801 // Verifies the UI elements are accessibile on the Bandwidth Management Settings 801 // Verifies the UI elements are accessibile on the Bandwidth Management Settings
802 // page. 802 // page.
803 - (void)testAccessibilityOnBandwidthManagementSettingsPage { 803 - (void)testAccessibilityOnBandwidthManagementSettingsPage {
804 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( 804 [self openSubSettingMenu:chrome_test_util::ButtonWithAccessibilityLabelId(
805 IDS_IOS_BANDWIDTH_MANAGEMENT_SETTINGS)]; 805 IDS_IOS_BANDWIDTH_MANAGEMENT_SETTINGS)];
806 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 806 chrome_test_util::VerifyAccessibilityForCurrentScreen();
807 [self closeSubSettingsMenu]; 807 [self closeSubSettingsMenu];
808 } 808 }
809 809
810 // Verifies the UI elements are accessible on the Save Passwords page. 810 // Verifies the UI elements are accessible on the Save Passwords page.
811 - (void)testAccessibilityOnSavePasswords { 811 - (void)testAccessibilityOnSavePasswords {
812 [ChromeEarlGreyUI openToolsMenu]; 812 [ChromeEarlGreyUI openToolsMenu];
813 [[EarlGrey selectElementWithMatcher:settingsButton()] 813 [[EarlGrey selectElementWithMatcher:SettingsButton()]
814 performAction:grey_tap()]; 814 performAction:grey_tap()];
815 [[EarlGrey selectElementWithMatcher:passwordsButton()] 815 [[EarlGrey selectElementWithMatcher:PasswordsButton()]
816 performAction:grey_tap()]; 816 performAction:grey_tap()];
817 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 817 chrome_test_util::VerifyAccessibilityForCurrentScreen();
818 [self closeSubSettingsMenu]; 818 [self closeSubSettingsMenu];
819 } 819 }
820 820
821 // Verifies the UI elements are accessible on the Search engine page. 821 // Verifies the UI elements are accessible on the Search engine page.
822 - (void)testAccessibilityOnSearchEngine { 822 - (void)testAccessibilityOnSearchEngine {
823 [ChromeEarlGreyUI openToolsMenu]; 823 [ChromeEarlGreyUI openToolsMenu];
824 [[EarlGrey selectElementWithMatcher:settingsButton()] 824 [[EarlGrey selectElementWithMatcher:SettingsButton()]
825 performAction:grey_tap()]; 825 performAction:grey_tap()];
826 [[EarlGrey selectElementWithMatcher:searchEngineButton()] 826 [[EarlGrey selectElementWithMatcher:SearchEngineButton()]
827 performAction:grey_tap()]; 827 performAction:grey_tap()];
828 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 828 chrome_test_util::VerifyAccessibilityForCurrentScreen();
829 [self closeSubSettingsMenu]; 829 [self closeSubSettingsMenu];
830 } 830 }
831 831
832 // Verifies the UI elements are accessible on the Autofill Forms page. 832 // Verifies the UI elements are accessible on the Autofill Forms page.
833 - (void)testAccessibilityOnAutofillForms { 833 - (void)testAccessibilityOnAutofillForms {
834 [ChromeEarlGreyUI openToolsMenu]; 834 [ChromeEarlGreyUI openToolsMenu];
835 [[EarlGrey selectElementWithMatcher:settingsButton()] 835 [[EarlGrey selectElementWithMatcher:SettingsButton()]
836 performAction:grey_tap()]; 836 performAction:grey_tap()];
837 [[EarlGrey selectElementWithMatcher:autofillButton()] 837 [[EarlGrey selectElementWithMatcher:AutofillButton()]
838 performAction:grey_tap()]; 838 performAction:grey_tap()];
839 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 839 chrome_test_util::VerifyAccessibilityForCurrentScreen();
840 [self closeSubSettingsMenu]; 840 [self closeSubSettingsMenu];
841 } 841 }
842 842
843 // Verifies the UI elements are accessible on the Google Apps page. 843 // Verifies the UI elements are accessible on the Google Apps page.
844 - (void)testAccessibilityOnGoogleApps { 844 - (void)testAccessibilityOnGoogleApps {
845 [ChromeEarlGreyUI openToolsMenu]; 845 [ChromeEarlGreyUI openToolsMenu];
846 [[EarlGrey selectElementWithMatcher:settingsButton()] 846 [[EarlGrey selectElementWithMatcher:SettingsButton()]
847 performAction:grey_tap()]; 847 performAction:grey_tap()];
848 [[EarlGrey selectElementWithMatcher:googleAppsButton()] 848 [[EarlGrey selectElementWithMatcher:GoogleAppsButton()]
849 performAction:grey_tap()]; 849 performAction:grey_tap()];
850 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 850 chrome_test_util::VerifyAccessibilityForCurrentScreen();
851 [self closeSubSettingsMenu]; 851 [self closeSubSettingsMenu];
852 } 852 }
853 853
854 // Verifies the UI elements are accessible on the About Chrome page. 854 // Verifies the UI elements are accessible on the About Chrome page.
855 - (void)testAccessibilityOnGoogleChrome { 855 - (void)testAccessibilityOnGoogleChrome {
856 [self openSubSettingMenu:googleChromeButton()]; 856 [self openSubSettingMenu:GoogleChromeButton()];
857 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 857 chrome_test_util::VerifyAccessibilityForCurrentScreen();
858 [self closeSubSettingsMenu]; 858 [self closeSubSettingsMenu];
859 } 859 }
860 860
861 // Verifies the UI elements are accessible on the Voice Search page. 861 // Verifies the UI elements are accessible on the Voice Search page.
862 - (void)testAccessibilityOnVoiceSearch { 862 - (void)testAccessibilityOnVoiceSearch {
863 [self openSubSettingMenu:voiceSearchButton()]; 863 [self openSubSettingMenu:VoiceSearchButton()];
864 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 864 chrome_test_util::VerifyAccessibilityForCurrentScreen();
865 [self closeSubSettingsMenu]; 865 [self closeSubSettingsMenu];
866 } 866 }
867 867
868 // Verifies the UI elements are accessible on the Passwords page. 868 // Verifies the UI elements are accessible on the Passwords page.
869 - (void)testAccessibilityOnPasswords { 869 - (void)testAccessibilityOnPasswords {
870 [ChromeEarlGreyUI openToolsMenu]; 870 [ChromeEarlGreyUI openToolsMenu];
871 [[EarlGrey selectElementWithMatcher:settingsButton()] 871 [[EarlGrey selectElementWithMatcher:SettingsButton()]
872 performAction:grey_tap()]; 872 performAction:grey_tap()];
873 [[EarlGrey selectElementWithMatcher:passwordsButton()] 873 [[EarlGrey selectElementWithMatcher:PasswordsButton()]
874 performAction:grey_tap()]; 874 performAction:grey_tap()];
875 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 875 chrome_test_util::VerifyAccessibilityForCurrentScreen();
876 [self closeSubSettingsMenu]; 876 [self closeSubSettingsMenu];
877 } 877 }
878 878
879 @end 879 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698