| 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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 response[web::test::HttpServer::MakeUrl(kUrlWithSetCookie)] = | 614 response[web::test::HttpServer::MakeUrl(kUrlWithSetCookie)] = |
| 615 std::pair<std::string, std::string>(base::SysNSStringToUTF8(cookieForURL), | 615 std::pair<std::string, std::string>(base::SysNSStringToUTF8(cookieForURL), |
| 616 kResponseWithSetCookie); | 616 kResponseWithSetCookie); |
| 617 response[web::test::HttpServer::MakeUrl(kUrl)] = | 617 response[web::test::HttpServer::MakeUrl(kUrl)] = |
| 618 std::pair<std::string, std::string>("", kResponse); | 618 std::pair<std::string, std::string>("", kResponse); |
| 619 | 619 |
| 620 web::test::SetUpSimpleHttpServerWithSetCookies(response); | 620 web::test::SetUpSimpleHttpServerWithSetCookies(response); |
| 621 | 621 |
| 622 // Load |kUrl| and check that cookie is not set. | 622 // Load |kUrl| and check that cookie is not set. |
| 623 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; | 623 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; |
| 624 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( | 624 [ChromeEarlGrey waitForWebViewContainingText:kResponse]; |
| 625 kResponse)] | |
| 626 assertWithMatcher:grey_notNil()]; | |
| 627 | 625 |
| 628 NSDictionary* cookies = [ChromeEarlGrey cookies]; | 626 NSDictionary* cookies = [ChromeEarlGrey cookies]; |
| 629 GREYAssertEqual(0U, cookies.count, @"No cookie should be found."); | 627 GREYAssertEqual(0U, cookies.count, @"No cookie should be found."); |
| 630 | 628 |
| 631 // Visit |kUrlWithSetCookie| to set a cookie and then load |kUrl| to check it | 629 // Visit |kUrlWithSetCookie| to set a cookie and then load |kUrl| to check it |
| 632 // is still set. | 630 // is still set. |
| 633 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrlWithSetCookie)]; | 631 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrlWithSetCookie)]; |
| 634 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( | 632 [ChromeEarlGrey waitForWebViewContainingText:kResponseWithSetCookie]; |
| 635 kResponseWithSetCookie)] | |
| 636 assertWithMatcher:grey_notNil()]; | |
| 637 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; | 633 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; |
| 638 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( | 634 [ChromeEarlGrey waitForWebViewContainingText:kResponse]; |
| 639 kResponse)] | |
| 640 assertWithMatcher:grey_notNil()]; | |
| 641 | 635 |
| 642 cookies = [ChromeEarlGrey cookies]; | 636 cookies = [ChromeEarlGrey cookies]; |
| 643 GREYAssertEqualObjects(kCookieValue, cookies[kCookieName], | 637 GREYAssertEqualObjects(kCookieValue, cookies[kCookieName], |
| 644 @"Failed to set cookie."); | 638 @"Failed to set cookie."); |
| 645 GREYAssertEqual(1U, cookies.count, @"Only one cookie should be found."); | 639 GREYAssertEqual(1U, cookies.count, @"Only one cookie should be found."); |
| 646 | 640 |
| 647 // Restore the Clear Browsing Data checkmarks prefs to their default state | 641 // Restore the Clear Browsing Data checkmarks prefs to their default state |
| 648 // in Teardown. | 642 // in Teardown. |
| 649 __weak SettingsTestCase* weakSelf = self; | 643 __weak SettingsTestCase* weakSelf = self; |
| 650 [self setTearDownHandler:^{ | 644 [self setTearDownHandler:^{ |
| 651 [weakSelf restoreClearBrowsingDataCheckmarksToDefault]; | 645 [weakSelf restoreClearBrowsingDataCheckmarksToDefault]; |
| 652 }]; | 646 }]; |
| 653 | 647 |
| 654 // Clear all cookies. | 648 // Clear all cookies. |
| 655 [self clearCookiesAndSiteData]; | 649 [self clearCookiesAndSiteData]; |
| 656 | 650 |
| 657 // Reload and test that there are no cookies left. | 651 // Reload and test that there are no cookies left. |
| 658 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; | 652 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]; |
| 659 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( | 653 [ChromeEarlGrey waitForWebViewContainingText:kResponse]; |
| 660 kResponse)] | |
| 661 assertWithMatcher:grey_notNil()]; | |
| 662 | 654 |
| 663 cookies = [ChromeEarlGrey cookies]; | 655 cookies = [ChromeEarlGrey cookies]; |
| 664 GREYAssertEqual(0U, cookies.count, @"No cookie should be found."); | 656 GREYAssertEqual(0U, cookies.count, @"No cookie should be found."); |
| 665 | 657 |
| 666 chrome_test_util::CloseAllTabs(); | 658 chrome_test_util::CloseAllTabs(); |
| 667 } | 659 } |
| 668 | 660 |
| 669 // Verifies that logging into a form on a web page allows the user to save and | 661 // Verifies that logging into a form on a web page allows the user to save and |
| 670 // then clear a password. | 662 // then clear a password. |
| 671 - (void)testClearPasswords { | 663 - (void)testClearPasswords { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 // Verifies the UI elements are accessible on the Send Usage Data page. | 978 // Verifies the UI elements are accessible on the Send Usage Data page. |
| 987 - (void)testAccessibilityOnSendUsageData { | 979 - (void)testAccessibilityOnSendUsageData { |
| 988 [ChromeEarlGreyUI openSettingsMenu]; | 980 [ChromeEarlGreyUI openSettingsMenu]; |
| 989 [ChromeEarlGreyUI tapSettingsMenuButton:PrivacyButton()]; | 981 [ChromeEarlGreyUI tapSettingsMenuButton:PrivacyButton()]; |
| 990 [ChromeEarlGreyUI tapPrivacyMenuButton:SendUsageDataButton()]; | 982 [ChromeEarlGreyUI tapPrivacyMenuButton:SendUsageDataButton()]; |
| 991 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 983 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 992 [self closeSubSettingsMenu]; | 984 [self closeSubSettingsMenu]; |
| 993 } | 985 } |
| 994 | 986 |
| 995 @end | 987 @end |
| OLD | NEW |