Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | |
| 122 // Matcher for the Search Engine cell on the main Settings screen. | 121 // Matcher for the Search Engine cell on the main Settings screen. |
| 123 id<GREYMatcher> SearchEngineButton() { | 122 id<GREYMatcher> SearchEngineButton() { |
| 124 return ButtonWithAccessibilityLabelId(IDS_IOS_SEARCH_ENGINE_SETTING_TITLE); | 123 return ButtonWithAccessibilityLabelId(IDS_IOS_SEARCH_ENGINE_SETTING_TITLE); |
| 125 } | 124 } |
| 126 | |
| 127 // Matcher for the Autofill Forms cell on the main Settings screen. | 125 // Matcher for the Autofill Forms cell on the main Settings screen. |
| 128 id<GREYMatcher> AutofillButton() { | 126 id<GREYMatcher> AutofillButton() { |
| 129 return ButtonWithAccessibilityLabelId(IDS_IOS_AUTOFILL); | 127 return ButtonWithAccessibilityLabelId(IDS_IOS_AUTOFILL); |
| 130 } | 128 } |
| 131 | |
| 132 // Matcher for the Google Apps cell on the main Settings screen. | 129 // Matcher for the Google Apps cell on the main Settings screen. |
| 133 id<GREYMatcher> GoogleAppsButton() { | 130 id<GREYMatcher> GoogleAppsButton() { |
| 134 return ButtonWithAccessibilityLabelId(IDS_IOS_GOOGLE_APPS_SM_SETTINGS); | 131 return ButtonWithAccessibilityLabelId(IDS_IOS_GOOGLE_APPS_SM_SETTINGS); |
| 135 } | 132 } |
| 136 | |
| 137 // Matcher for the Google Chrome cell on the main Settings screen. | 133 // Matcher for the Google Chrome cell on the main Settings screen. |
| 138 id<GREYMatcher> GoogleChromeButton() { | 134 id<GREYMatcher> GoogleChromeButton() { |
| 139 return ButtonWithAccessibilityLabelId(IDS_IOS_PRODUCT_NAME); | 135 return ButtonWithAccessibilityLabelId(IDS_IOS_PRODUCT_NAME); |
| 140 } | 136 } |
| 141 | |
| 142 // Matcher for the Google Chrome cell on the main Settings screen. | 137 // Matcher for the Google Chrome cell on the main Settings screen. |
| 143 id<GREYMatcher> VoiceSearchButton() { | 138 id<GREYMatcher> VoiceSearchButton() { |
| 144 return grey_allOf(grey_accessibilityID(kSettingsVoiceSearchCellId), | 139 return grey_allOf(grey_accessibilityID(kSettingsVoiceSearchCellId), |
| 145 grey_accessibilityTrait(UIAccessibilityTraitButton), nil); | 140 grey_accessibilityTrait(UIAccessibilityTraitButton), nil); |
| 146 } | 141 } |
| 147 | |
| 148 // Matcher for the Preload Webpages button on the bandwidth UI. | 142 // Matcher for the Preload Webpages button on the bandwidth UI. |
| 149 id<GREYMatcher> BandwidthPreloadWebpagesButton() { | 143 id<GREYMatcher> BandwidthPreloadWebpagesButton() { |
| 150 return ButtonWithAccessibilityLabelId(IDS_IOS_OPTIONS_PRELOAD_WEBPAGES); | 144 return ButtonWithAccessibilityLabelId(IDS_IOS_OPTIONS_PRELOAD_WEBPAGES); |
| 151 } | 145 } |
| 152 | |
| 153 // Matcher for the Privacy Handoff button on the privacy UI. | 146 // Matcher for the Privacy Handoff button on the privacy UI. |
| 154 id<GREYMatcher> PrivacyHandoffButton() { | 147 id<GREYMatcher> PrivacyHandoffButton() { |
| 155 return ButtonWithAccessibilityLabelId( | 148 return ButtonWithAccessibilityLabelId( |
| 156 IDS_IOS_OPTIONS_ENABLE_HANDOFF_TO_OTHER_DEVICES); | 149 IDS_IOS_OPTIONS_ENABLE_HANDOFF_TO_OTHER_DEVICES); |
| 157 } | 150 } |
| 158 | |
| 159 // Matcher for the Privacy Block Popups button on the privacy UI. | 151 // Matcher for the Privacy Block Popups button on the privacy UI. |
| 160 id<GREYMatcher> BlockPopupsButton() { | 152 id<GREYMatcher> BlockPopupsButton() { |
| 161 return ButtonWithAccessibilityLabelId(IDS_IOS_BLOCK_POPUPS); | 153 return ButtonWithAccessibilityLabelId(IDS_IOS_BLOCK_POPUPS); |
| 162 } | 154 } |
| 163 | |
| 164 // Matcher for the Privacy Translate Settings button on the privacy UI. | 155 // Matcher for the Privacy Translate Settings button on the privacy UI. |
| 165 id<GREYMatcher> TranslateSettingsButton() { | 156 id<GREYMatcher> TranslateSettingsButton() { |
| 166 return ButtonWithAccessibilityLabelId(IDS_IOS_TRANSLATE_SETTING); | 157 return ButtonWithAccessibilityLabelId(IDS_IOS_TRANSLATE_SETTING); |
| 167 } | 158 } |
| 159 // Matcher for the save button in the save password bar. | |
| 160 id<GREYMatcher> savePasswordButton() { | |
| 161 return ButtonWithAccessibilityLabelId(IDS_IOS_PASSWORD_MANAGER_SAVE_BUTTON); | |
| 162 } | |
| 168 | 163 |
| 169 // Asserts that there is no cookie in current web state. | 164 // Asserts that there is no cookie in current web state. |
| 170 void AssertNoCookieExists() { | 165 void AssertNoCookieExists() { |
| 171 NSError* error = nil; | 166 NSError* error = nil; |
| 172 chrome_test_util::ExecuteJavaScript( | 167 chrome_test_util::ExecuteJavaScript( |
| 173 base::SysUTF8ToNSString(kJavaScriptGetCookies), &error); | 168 base::SysUTF8ToNSString(kJavaScriptGetCookies), &error); |
| 174 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( | 169 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( |
| 175 kNoCookieText)] | 170 kNoCookieText)] |
| 176 assertWithMatcher:grey_notNil()]; | 171 assertWithMatcher:grey_notNil()]; |
| 177 } | 172 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 [[EarlGrey selectElementWithMatcher:ClearCookiesButton()] | 386 [[EarlGrey selectElementWithMatcher:ClearCookiesButton()] |
| 392 performAction:grey_tap()]; | 387 performAction:grey_tap()]; |
| 393 [[EarlGrey selectElementWithMatcher:ClearCacheButton()] | 388 [[EarlGrey selectElementWithMatcher:ClearCacheButton()] |
| 394 performAction:grey_tap()]; | 389 performAction:grey_tap()]; |
| 395 [[EarlGrey selectElementWithMatcher:ClearSavedPasswordsButton()] | 390 [[EarlGrey selectElementWithMatcher:ClearSavedPasswordsButton()] |
| 396 performAction:grey_tap()]; | 391 performAction:grey_tap()]; |
| 397 | 392 |
| 398 [self dismissSettings]; | 393 [self dismissSettings]; |
| 399 } | 394 } |
| 400 | 395 |
| 396 // Enable password management. | |
| 397 - (void)enablePasswordManagement { | |
| 398 ios::ChromeBrowserState* browserState = | |
| 399 chrome_test_util::GetOriginalBrowserState(); | |
| 400 PrefService* preferences = browserState->GetPrefs(); | |
| 401 preferences->SetBoolean( | |
| 402 password_manager::prefs::kPasswordManagerSavingEnabled, true); | |
| 403 } | |
| 404 | |
| 405 // Return pref for password management back to default and restore the Clear | |
| 406 // Browsing Data checkmarks prefs to their default state. | |
| 407 - (void)passwordsTearDown:(BOOL)defaultPasswordManagementSetting { | |
| 408 ios::ChromeBrowserState* browserState = | |
| 409 chrome_test_util::GetOriginalBrowserState(); | |
| 410 PrefService* preferences = browserState->GetPrefs(); | |
| 411 preferences->SetBoolean( | |
| 412 password_manager::prefs::kPasswordManagerSavingEnabled, true); | |
| 413 [self clearPasswords]; | |
| 414 | |
| 415 // Restore the password management pref state. | |
| 416 preferences->SetBoolean( | |
| 417 password_manager::prefs::kPasswordManagerSavingEnabled, | |
| 418 defaultPasswordManagementSetting); | |
| 419 | |
| 420 // Restore the Clear Browsing Data checkmarks prefs to their default state. | |
| 421 [self restoreClearBrowsingDataCheckmarksToDefault]; | |
| 422 } | |
| 423 | |
| 424 // Restore the Clear Browsing Data checkmarks prefs to their default state. | |
| 425 - (void)restoreClearBrowsingDataCheckmarksToDefault { | |
| 426 ios::ChromeBrowserState* browserState = | |
| 427 chrome_test_util::GetOriginalBrowserState(); | |
| 428 PrefService* preferences = browserState->GetPrefs(); | |
| 429 preferences->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, true); | |
| 430 preferences->SetBoolean(browsing_data::prefs::kDeleteCache, true); | |
| 431 preferences->SetBoolean(browsing_data::prefs::kDeleteCookies, true); | |
| 432 preferences->SetBoolean(browsing_data::prefs::kDeletePasswords, false); | |
| 433 preferences->SetBoolean(browsing_data::prefs::kDeleteFormData, false); | |
| 434 } | |
| 435 | |
| 401 // Checks the presence (or absence) of saved passwords. | 436 // Checks the presence (or absence) of saved passwords. |
| 402 // If |saved| is YES, it checks that there is a Saved Passwords section. | 437 // If |saved| is YES, it checks that there is a Saved Passwords section. |
| 403 // If |saved| is NO, it checks that there is no Saved Passwords section. | 438 // If |saved| is NO, it checks that there is no Saved Passwords section. |
| 404 - (void)checkIfPasswordsSaved:(BOOL)saved { | 439 - (void)checkIfPasswordsSaved:(BOOL)saved { |
| 405 [ChromeEarlGreyUI openToolsMenu]; | 440 [ChromeEarlGreyUI openToolsMenu]; |
| 406 [[EarlGrey selectElementWithMatcher:SettingsButton()] | 441 [[EarlGrey selectElementWithMatcher:SettingsButton()] |
| 407 performAction:grey_tap()]; | 442 performAction:grey_tap()]; |
| 408 [[EarlGrey selectElementWithMatcher:PasswordsButton()] | 443 [[EarlGrey selectElementWithMatcher:PasswordsButton()] |
| 409 performAction:grey_tap()]; | 444 performAction:grey_tap()]; |
| 410 | 445 |
| 411 id<GREYMatcher> visibilityMatcher = | 446 id<GREYMatcher> visibilityMatcher = |
| 412 saved ? grey_sufficientlyVisible() : grey_notVisible(); | 447 saved ? grey_sufficientlyVisible() : grey_notVisible(); |
| 413 [[EarlGrey selectElementWithMatcher: | 448 [[EarlGrey selectElementWithMatcher: |
| 414 grey_text(l10n_util::GetNSString( | 449 grey_text(l10n_util::GetNSString( |
| 415 IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE))] | 450 IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE))] |
| 416 assertWithMatcher:visibilityMatcher]; | 451 assertWithMatcher:visibilityMatcher]; |
| 417 | 452 |
| 418 // Close the Settings. | 453 // Close the Settings. |
| 419 [self closeSubSettingsMenu]; | 454 [self closeSubSettingsMenu]; |
| 420 } | 455 } |
| 421 | 456 |
| 457 // Loads a page with a login and submits it. | |
| 458 - (void)loadFormAndLogin { | |
| 459 std::map<GURL, std::string> responses; | |
| 460 const GURL URL = web::test::HttpServer::MakeUrl("http://testClearPasswords"); | |
| 461 | |
| 462 // TODO(crbug.com/432596): There looks to be a bug where the save password | |
| 463 // infobar is not displayed if the action is about:blank. | |
| 464 responses[URL] = | |
| 465 "<form method=\"POST\" action=\"dest\">" | |
| 466 "Username:<input type=\"text\" name=\"username\" value=\"name\" /><br />" | |
| 467 "Password:<input type=\"password\"" | |
| 468 "name=\"password\" value=\"pass\"/><br />" | |
| 469 "<input type=\"submit\" value=\"Login\" id=\"Login\"/>" | |
| 470 "</form>"; | |
| 471 const GURL destinationURL = | |
| 472 web::test::HttpServer::MakeUrl("http://testClearPasswords/dest"); | |
| 473 responses[destinationURL] = "Logged in!"; | |
| 474 web::test::SetUpSimpleHttpServer(responses); | |
| 475 | |
| 476 // Login to page and click to save password and check that its saved. | |
| 477 [ChromeEarlGrey loadURL:URL]; | |
| 478 chrome_test_util::TapWebViewElementWithId("Login"); | |
| 479 [[EarlGrey selectElementWithMatcher:savePasswordButton()] | |
| 480 performAction:grey_tap()]; | |
| 481 } | |
| 482 | |
| 483 // Opens the passwords page from the NTP. It requires no menus to be open. | |
| 484 - (void)openPasswordSettings { | |
| 485 // Open settings and verify data in the view controller. | |
| 486 [ChromeEarlGreyUI openToolsMenu]; | |
| 487 [[EarlGrey | |
| 488 selectElementWithMatcher:grey_accessibilityID(kToolsMenuSettingsId)] | |
| 489 performAction:grey_tap()]; | |
| 490 [[EarlGrey selectElementWithMatcher:PasswordsButton()] | |
| 491 performAction:grey_tap()]; | |
| 492 } | |
| 493 | |
| 422 // Checks for a given service that it is both recording and uploading, where | 494 // Checks for a given service that it is both recording and uploading, where |
| 423 // appropriate. | 495 // appropriate. |
| 424 - (void)assertMetricsServiceEnabled:(MetricsServiceType)serviceType { | 496 - (void)assertMetricsServiceEnabled:(MetricsServiceType)serviceType { |
| 425 switch (serviceType) { | 497 switch (serviceType) { |
| 426 case kMetrics: | 498 case kMetrics: |
| 427 GREYAssertTrue(chrome_test_util::IsMetricsRecordingEnabled(), | 499 GREYAssertTrue(chrome_test_util::IsMetricsRecordingEnabled(), |
| 428 @"Metrics recording should be enabled."); | 500 @"Metrics recording should be enabled."); |
| 429 GREYAssertTrue(chrome_test_util::IsMetricsReportingEnabled(), | 501 GREYAssertTrue(chrome_test_util::IsMetricsReportingEnabled(), |
| 430 @"Metrics reporting should be enabled."); | 502 @"Metrics reporting should be enabled."); |
| 431 break; | 503 break; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; | 697 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; |
| 626 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( | 698 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( |
| 627 kResponse)] | 699 kResponse)] |
| 628 assertWithMatcher:grey_notNil()]; | 700 assertWithMatcher:grey_notNil()]; |
| 629 | 701 |
| 630 AssertCookieExists(kCookie); | 702 AssertCookieExists(kCookie); |
| 631 | 703 |
| 632 // Restore the Clear Browsing Data checkmarks prefs to their default state in | 704 // Restore the Clear Browsing Data checkmarks prefs to their default state in |
| 633 // Teardown. | 705 // Teardown. |
| 634 [self setTearDownHandler:^{ | 706 [self setTearDownHandler:^{ |
| 635 ios::ChromeBrowserState* browserState = | 707 [self restoreClearBrowsingDataCheckmarksToDefault]; |
| 636 chrome_test_util::GetOriginalBrowserState(); | |
| 637 PrefService* preferences = browserState->GetPrefs(); | |
| 638 | |
| 639 preferences->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, true); | |
| 640 preferences->SetBoolean(browsing_data::prefs::kDeleteCache, true); | |
| 641 preferences->SetBoolean(browsing_data::prefs::kDeleteCookies, true); | |
| 642 preferences->SetBoolean(browsing_data::prefs::kDeletePasswords, false); | |
| 643 preferences->SetBoolean(browsing_data::prefs::kDeleteFormData, false); | |
| 644 }]; | 708 }]; |
| 645 | 709 |
| 646 // Clear all cookies. | 710 // Clear all cookies. |
| 647 [self clearCookiesAndSiteData]; | 711 [self clearCookiesAndSiteData]; |
| 648 | 712 |
| 649 // Reload and test that there are no cookies left. | 713 // Reload and test that there are no cookies left. |
| 650 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; | 714 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; |
| 651 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( | 715 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( |
| 652 kResponse)] | 716 kResponse)] |
| 653 assertWithMatcher:grey_notNil()]; | 717 assertWithMatcher:grey_notNil()]; |
| 654 AssertNoCookieExists(); | 718 AssertNoCookieExists(); |
| 655 chrome_test_util::CloseAllTabs(); | 719 chrome_test_util::CloseAllTabs(); |
| 656 } | 720 } |
| 657 | 721 |
| 658 // Verifies that logging into a form on a web page allows the user to save and | 722 // Verifies that logging into a form on a web page allows the user to save and |
| 659 // then clear a password. | 723 // then clear a password. |
| 660 - (void)testClearPasswords { | 724 - (void)testClearPasswords { |
| 661 std::map<GURL, std::string> responses; | |
| 662 const GURL URL = web::test::HttpServer::MakeUrl("http://testClearPasswords"); | |
| 663 // TODO(crbug.com/432596): There looks to be a bug where the save password | |
| 664 // infobar is not displayed if the action is about:blank. | |
| 665 responses[URL] = | |
| 666 "<form method=\"POST\" action=\"dest\">" | |
| 667 "Username:<input type=\"text\" name=\"username\" value=\"name\" /><br />" | |
| 668 "Password:<input type=\"password\"" | |
| 669 "name=\"password\" value=\"pass\"/><br />" | |
| 670 "<input type=\"submit\" value=\"Login\" id=\"Login\"/>" | |
| 671 "</form>"; | |
| 672 const GURL destinationURL = | |
| 673 web::test::HttpServer::MakeUrl("http://testClearPasswords/dest"); | |
| 674 responses[destinationURL] = "Logged in!"; | |
| 675 web::test::SetUpSimpleHttpServer(responses); | |
| 676 | 725 |
| 677 // Enable password management. | |
| 678 ios::ChromeBrowserState* browserState = | 726 ios::ChromeBrowserState* browserState = |
| 679 chrome_test_util::GetOriginalBrowserState(); | 727 chrome_test_util::GetOriginalBrowserState(); |
| 680 PrefService* preferences = browserState->GetPrefs(); | 728 PrefService* preferences = browserState->GetPrefs(); |
| 681 bool originalPasswordManagerSavingEnabled = preferences->GetBoolean( | 729 bool defaultPasswordManagerSavingPref = preferences->GetBoolean( |
| 682 password_manager::prefs::kPasswordManagerSavingEnabled); | 730 password_manager::prefs::kPasswordManagerSavingEnabled); |
| 683 preferences->SetBoolean( | 731 |
| 684 password_manager::prefs::kPasswordManagerSavingEnabled, true); | 732 [self enablePasswordManagement]; |
| 685 [self setTearDownHandler:^{ | 733 [self setTearDownHandler:^{ |
| 686 // Restore the password management pref state. | 734 [self passwordsTearDown:defaultPasswordManagerSavingPref]; |
| 687 ios::ChromeBrowserState* browserState = | |
| 688 chrome_test_util::GetOriginalBrowserState(); | |
| 689 PrefService* preferences = browserState->GetPrefs(); | |
| 690 preferences->SetBoolean( | |
| 691 password_manager::prefs::kPasswordManagerSavingEnabled, | |
| 692 originalPasswordManagerSavingEnabled); | |
| 693 | |
| 694 // Restore the Clear Browsing Data checkmarks prefs to their default state. | |
| 695 preferences->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, true); | |
| 696 preferences->SetBoolean(browsing_data::prefs::kDeleteCache, true); | |
| 697 preferences->SetBoolean(browsing_data::prefs::kDeleteCookies, true); | |
| 698 preferences->SetBoolean(browsing_data::prefs::kDeletePasswords, false); | |
| 699 preferences->SetBoolean(browsing_data::prefs::kDeleteFormData, false); | |
| 700 }]; | 735 }]; |
| 701 | 736 |
| 702 // Clear passwords and check that none are saved. | 737 // Clear passwords and check that none are saved. |
| 703 [self clearPasswords]; | 738 [self clearPasswords]; |
| 704 [self checkIfPasswordsSaved:NO]; | 739 [self checkIfPasswordsSaved:NO]; |
| 705 | 740 |
| 706 // Login to page and click to save password and check that its saved. | 741 // Login to page and click to save password and check that its saved. |
| 707 [ChromeEarlGrey loadURL:URL]; | 742 [self loadFormAndLogin]; |
| 708 chrome_test_util::TapWebViewElementWithId("Login"); | |
| 709 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( | |
| 710 IDS_IOS_PASSWORD_MANAGER_SAVE_BUTTON)] | |
| 711 performAction:grey_tap()]; | |
| 712 | |
| 713 [self checkIfPasswordsSaved:YES]; | 743 [self checkIfPasswordsSaved:YES]; |
| 714 | |
| 715 // Clear passwords and check that none are saved. | |
| 716 [self clearPasswords]; | |
| 717 [self checkIfPasswordsSaved:NO]; | |
| 718 } | 744 } |
| 719 | 745 |
| 720 // Verifies that metrics reporting works properly under possible settings of the | 746 // Verifies that metrics reporting works properly under possible settings of the |
| 721 // preferences kMetricsReportingEnabled and kMetricsReportingWifiOnly. | 747 // preferences kMetricsReportingEnabled and kMetricsReportingWifiOnly. |
| 722 - (void)testMetricsReporting { | 748 - (void)testMetricsReporting { |
| 723 [self assertsMetricsPrefsForService:kMetrics]; | 749 [self assertsMetricsPrefsForService:kMetrics]; |
| 724 } | 750 } |
| 725 | 751 |
| 726 // Verifies that breakpad reporting works properly under possible settings of | 752 // Verifies that breakpad reporting works properly under possible settings of |
| 727 // the preferences |kMetricsReportingEnabled| and |kMetricsReportingWifiOnly| | 753 // the preferences |kMetricsReportingEnabled| and |kMetricsReportingWifiOnly| |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 753 [self assertsMetricsPrefsForService:kBreakpadFirstLaunch]; | 779 [self assertsMetricsPrefsForService:kBreakpadFirstLaunch]; |
| 754 } | 780 } |
| 755 | 781 |
| 756 // Set a server bound certificate, clears the site data through the UI and | 782 // Set a server bound certificate, clears the site data through the UI and |
| 757 // checks that the certificate is deleted. | 783 // checks that the certificate is deleted. |
| 758 - (void)testClearCertificates { | 784 - (void)testClearCertificates { |
| 759 SetCertificate(); | 785 SetCertificate(); |
| 760 // Restore the Clear Browsing Data checkmarks prefs to their default state in | 786 // Restore the Clear Browsing Data checkmarks prefs to their default state in |
| 761 // Teardown. | 787 // Teardown. |
| 762 [self setTearDownHandler:^{ | 788 [self setTearDownHandler:^{ |
| 763 ios::ChromeBrowserState* browserState = | 789 [self restoreClearBrowsingDataCheckmarksToDefault]; |
|
liaoyuke
2017/02/23 17:59:11
Thank you for cleaning this up, outside of your co
| |
| 764 chrome_test_util::GetOriginalBrowserState(); | |
| 765 PrefService* preferences = browserState->GetPrefs(); | |
| 766 | |
| 767 preferences->SetBoolean(browsing_data::prefs::kDeleteBrowsingHistory, true); | |
| 768 preferences->SetBoolean(browsing_data::prefs::kDeleteCache, true); | |
| 769 preferences->SetBoolean(browsing_data::prefs::kDeleteCookies, true); | |
| 770 preferences->SetBoolean(browsing_data::prefs::kDeletePasswords, false); | |
| 771 preferences->SetBoolean(browsing_data::prefs::kDeleteFormData, false); | |
| 772 }]; | 790 }]; |
| 773 GREYAssertFalse(IsCertificateCleared(), @"Failed to set certificate."); | 791 GREYAssertFalse(IsCertificateCleared(), @"Failed to set certificate."); |
| 774 [self clearCookiesAndSiteData]; | 792 [self clearCookiesAndSiteData]; |
| 775 GREYAssertTrue(IsCertificateCleared(), | 793 GREYAssertTrue(IsCertificateCleared(), |
| 776 @"Certificate is expected to be deleted."); | 794 @"Certificate is expected to be deleted."); |
| 777 } | 795 } |
| 778 | 796 |
| 779 // Verifies that Settings opens when signed-out and in Incognito mode. | 797 // Verifies that Settings opens when signed-out and in Incognito mode. |
| 780 // This tests that crbug.com/607335 has not regressed. | 798 // This tests that crbug.com/607335 has not regressed. |
| 781 - (void)testSettingsSignedOutIncognito { | 799 - (void)testSettingsSignedOutIncognito { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 | 956 |
| 939 // Verifies the UI elements are accessible on the Voice Search page. | 957 // Verifies the UI elements are accessible on the Voice Search page. |
| 940 - (void)testAccessibilityOnVoiceSearch { | 958 - (void)testAccessibilityOnVoiceSearch { |
| 941 [self openSubSettingMenu:VoiceSearchButton()]; | 959 [self openSubSettingMenu:VoiceSearchButton()]; |
| 942 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 960 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 943 [self closeSubSettingsMenu]; | 961 [self closeSubSettingsMenu]; |
| 944 } | 962 } |
| 945 | 963 |
| 946 // Verifies the UI elements are accessible on the Passwords page. | 964 // Verifies the UI elements are accessible on the Passwords page. |
| 947 - (void)testAccessibilityOnPasswords { | 965 - (void)testAccessibilityOnPasswords { |
| 948 [ChromeEarlGreyUI openToolsMenu]; | 966 [self openPasswordSettings]; |
| 949 [[EarlGrey selectElementWithMatcher:SettingsButton()] | |
| 950 performAction:grey_tap()]; | |
| 951 [[EarlGrey selectElementWithMatcher:PasswordsButton()] | |
| 952 performAction:grey_tap()]; | |
| 953 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 967 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 954 [self closeSubSettingsMenu]; | 968 [self closeSubSettingsMenu]; |
| 955 } | 969 } |
| 956 | 970 |
| 971 // Verifies that saved passwords are accessible in Passwords page. | |
| 972 - (void)testAccessibilityOnPasswordEditing { | |
| 973 [self clearPasswords]; | |
| 974 [self checkIfPasswordsSaved:NO]; | |
| 975 | |
| 976 ios::ChromeBrowserState* browserState = | |
| 977 chrome_test_util::GetOriginalBrowserState(); | |
| 978 PrefService* preferences = browserState->GetPrefs(); | |
|
liaoyuke
2017/02/23 17:59:11
nits: can you add a separate function this this pi
rohitrao (ping after 24h)
2017/02/23 21:39:22
I see EG tests as grey-box tests, so I'm fine with
| |
| 979 bool defaultPasswordManagerSavingPref = preferences->GetBoolean( | |
| 980 password_manager::prefs::kPasswordManagerSavingEnabled); | |
| 981 | |
| 982 [self enablePasswordManagement]; | |
| 983 [self setTearDownHandler:^{ | |
| 984 [self passwordsTearDown:defaultPasswordManagerSavingPref]; | |
| 985 }]; | |
| 986 | |
| 987 [self loadFormAndLogin]; | |
| 988 [self openPasswordSettings]; | |
| 989 | |
| 990 // Switch on edit mode. | |
| 991 [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( | |
| 992 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON)] | |
| 993 performAction:grey_tap()]; | |
| 994 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | |
| 995 | |
| 996 // Exit settings. | |
| 997 [[EarlGrey | |
| 998 selectElementWithMatcher:grey_allOf( | |
| 999 grey_accessibilityID(@"ic_arrow_back"), | |
| 1000 grey_accessibilityTrait( | |
| 1001 UIAccessibilityTraitButton), | |
| 1002 nil)] performAction:grey_tap()]; | |
| 1003 | |
| 1004 [[EarlGrey | |
| 1005 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( | |
| 1006 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] | |
| 1007 performAction:grey_tap()]; | |
| 1008 } | |
| 1009 | |
| 957 @end | 1010 @end |
| OLD | NEW |