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

Side by Side Diff: ios/chrome/browser/web/http_auth_egtest.mm

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: review comments Created 3 years, 6 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 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "components/strings/grit/components_strings.h" 9 #include "components/strings/grit/components_strings.h"
10 #include "ios/chrome/browser/ui/ui_util.h" 10 #include "ios/chrome/browser/ui/ui_util.h"
11 #include "ios/chrome/grit/ios_strings.h" 11 #include "ios/chrome/grit/ios_strings.h"
12 #include "ios/chrome/test/app/navigation_test_util.h" 12 #include "ios/chrome/test/app/navigation_test_util.h"
13 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
13 #import "ios/chrome/test/earl_grey/chrome_matchers.h" 14 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
14 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 15 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
15 #import "ios/testing/wait_util.h" 16 #import "ios/testing/wait_util.h"
16 #import "ios/web/public/test/http_server/http_auth_response_provider.h" 17 #import "ios/web/public/test/http_server/http_auth_response_provider.h"
17 #import "ios/web/public/test/http_server/http_server.h" 18 #import "ios/web/public/test/http_server/http_server.h"
18 #include "ios/web/public/test/http_server/http_server_util.h" 19 #include "ios/web/public/test/http_server/http_server_util.h"
19 #include "ui/base/l10n/l10n_util_mac.h" 20 #include "ui/base/l10n/l10n_util_mac.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
22 #if !defined(__has_feature) || !__has_feature(objc_arc) 23 #if !defined(__has_feature) || !__has_feature(objc_arc)
23 #error "This file requires ARC support." 24 #error "This file requires ARC support."
24 #endif 25 #endif
25 26
26 using testing::WaitUntilConditionOrTimeout; 27 using testing::WaitUntilConditionOrTimeout;
27 using testing::kWaitForPageLoadTimeout; 28 using testing::kWaitForPageLoadTimeout;
28 using chrome_test_util::WebViewContainingText;
29 29
30 namespace { 30 namespace {
31 31
32 // Returns matcher for HTTP Authentication dialog. 32 // Returns matcher for HTTP Authentication dialog.
33 id<GREYMatcher> HttpAuthDialog() { 33 id<GREYMatcher> HttpAuthDialog() {
34 NSString* title = l10n_util::GetNSStringWithFixup(IDS_LOGIN_DIALOG_TITLE); 34 NSString* title = l10n_util::GetNSStringWithFixup(IDS_LOGIN_DIALOG_TITLE);
35 return chrome_test_util::StaticTextWithAccessibilityLabel(title); 35 return chrome_test_util::StaticTextWithAccessibilityLabel(title);
36 } 36 }
37 37
38 // Returns matcher for Username text field. 38 // Returns matcher for Username text field.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 WaitForHttpAuthDialog(); 89 WaitForHttpAuthDialog();
90 90
91 // Enter valid username and password. 91 // Enter valid username and password.
92 [[EarlGrey selectElementWithMatcher:UsernameField()] 92 [[EarlGrey selectElementWithMatcher:UsernameField()]
93 performAction:grey_typeText(@"gooduser")]; 93 performAction:grey_typeText(@"gooduser")];
94 [[EarlGrey selectElementWithMatcher:PasswordField()] 94 [[EarlGrey selectElementWithMatcher:PasswordField()]
95 performAction:grey_typeText(@"goodpass")]; 95 performAction:grey_typeText(@"goodpass")];
96 [[EarlGrey selectElementWithMatcher:LoginButton()] performAction:grey_tap()]; 96 [[EarlGrey selectElementWithMatcher:LoginButton()] performAction:grey_tap()];
97 97
98 const std::string pageText = web::HttpAuthResponseProvider::page_text(); 98 const std::string pageText = web::HttpAuthResponseProvider::page_text();
99 [[EarlGrey selectElementWithMatcher:WebViewContainingText(pageText)] 99 [ChromeEarlGrey waitForWebViewContainingText:pageText];
100 assertWithMatcher:grey_notNil()];
101 } 100 }
102 101
103 // Tests Basic HTTP Authentication with incorrect username and password. 102 // Tests Basic HTTP Authentication with incorrect username and password.
104 - (void)testUnsuccessfullBasicAuth { 103 - (void)testUnsuccessfullBasicAuth {
105 if (IsIPadIdiom()) { 104 if (IsIPadIdiom()) {
106 // EG does not allow interactions with HTTP Dialog when loading spinner is 105 // EG does not allow interactions with HTTP Dialog when loading spinner is
107 // animated. TODO(crbug.com/680290): Enable this test on iPad when EarlGrey 106 // animated. TODO(crbug.com/680290): Enable this test on iPad when EarlGrey
108 // allows tapping dialog buttons with active page load spinner. 107 // allows tapping dialog buttons with active page load spinner.
109 EARL_GREY_TEST_DISABLED(@"Tab Title not displayed on handset."); 108 EARL_GREY_TEST_DISABLED(@"Tab Title not displayed on handset.");
110 } 109 }
(...skipping 30 matching lines...) Expand all
141 chrome_test_util::LoadUrl(URL); 140 chrome_test_util::LoadUrl(URL);
142 WaitForHttpAuthDialog(); 141 WaitForHttpAuthDialog();
143 142
144 [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()] 143 [[EarlGrey selectElementWithMatcher:chrome_test_util::CancelButton()]
145 performAction:grey_tap()]; 144 performAction:grey_tap()];
146 [[EarlGrey selectElementWithMatcher:HttpAuthDialog()] 145 [[EarlGrey selectElementWithMatcher:HttpAuthDialog()]
147 assertWithMatcher:grey_nil()]; 146 assertWithMatcher:grey_nil()];
148 } 147 }
149 148
150 @end 149 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/web/child_window_open_by_dom_egtest.mm ('k') | ios/chrome/browser/web/navigation_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698