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

Side by Side Diff: ios/web/test/web_int_test.mm

Issue 2644223002: Integration tests for WebStateDelegate::OnAuthRequired callback. (Closed)
Patch Set: Addressed review comments 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 unified diff | Download patch
« no previous file with comments | « ios/web/test/web_int_test.h ('k') | ios/web/web_state/http_auth_inttest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/web/test/web_int_test.h" 5 #import "ios/web/test/web_int_test.h"
6 6
7 #import "base/ios/block_types.h" 7 #import "base/ios/block_types.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #import "base/test/ios/wait_util.h" 9 #import "base/test/ios/wait_util.h"
10 #import "ios/web/public/test/http_server.h" 10 #import "ios/web/public/test/http_server.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Start the http server. 55 // Start the http server.
56 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); 56 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
57 ASSERT_FALSE(server.IsRunning()); 57 ASSERT_FALSE(server.IsRunning());
58 server.StartOrDie(); 58 server.StartOrDie();
59 59
60 // Remove any previously existing WKWebView data. 60 // Remove any previously existing WKWebView data.
61 RemoveWKWebViewCreatedData([WKWebsiteDataStore defaultDataStore], 61 RemoveWKWebViewCreatedData([WKWebsiteDataStore defaultDataStore],
62 [WKWebsiteDataStore allWebsiteDataTypes]); 62 [WKWebsiteDataStore allWebsiteDataTypes]);
63 63
64 // Create the WebState and its WebStateObserver. 64 // Create the WebState.
65 web::WebState::CreateParams web_state_create_params(GetBrowserState()); 65 web::WebState::CreateParams web_state_create_params(GetBrowserState());
66 web_state_ = web::WebState::Create(web_state_create_params); 66 web_state_ = web::WebState::Create(web_state_create_params);
67 observer_ = base::WrapUnique(new IntTestWebStateObserver(web_state()));
68 67
69 // Resize the webview so that pages can be properly rendered. 68 // Resize the webview so that pages can be properly rendered.
70 web_state()->GetView().frame = 69 web_state()->GetView().frame =
71 [UIApplication sharedApplication].keyWindow.bounds; 70 [UIApplication sharedApplication].keyWindow.bounds;
72 71
73 // Enable web usage for the WebState. 72 // Enable web usage for the WebState.
74 web_state()->SetWebUsageEnabled(true); 73 web_state()->SetWebUsageEnabled(true);
74
75 web_state()->SetDelegate(&web_state_delegate_);
75 } 76 }
76 77
77 void WebIntTest::TearDown() { 78 void WebIntTest::TearDown() {
78 RemoveWKWebViewCreatedData([WKWebsiteDataStore defaultDataStore], 79 RemoveWKWebViewCreatedData([WKWebsiteDataStore defaultDataStore],
79 [WKWebsiteDataStore allWebsiteDataTypes]); 80 [WKWebsiteDataStore allWebsiteDataTypes]);
80 81
81 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); 82 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
82 server.Stop(); 83 server.Stop();
83 EXPECT_FALSE(server.IsRunning()); 84 EXPECT_FALSE(server.IsRunning());
84 85
85 WebTest::TearDown(); 86 WebTest::TearDown();
86 } 87 }
87 88
88 id WebIntTest::ExecuteJavaScript(NSString* script) { 89 id WebIntTest::ExecuteJavaScript(NSString* script) {
89 return web::ExecuteJavaScript(web_state()->GetJSInjectionReceiver(), script); 90 return web::ExecuteJavaScript(web_state()->GetJSInjectionReceiver(), script);
90 } 91 }
91 92
92 void WebIntTest::ExecuteBlockAndWaitForLoad(const GURL& url, 93 void WebIntTest::ExecuteBlockAndWaitForLoad(const GURL& url,
93 ProceduralBlock block) { 94 ProceduralBlock block) {
94 DCHECK(block); 95 DCHECK(block);
96 observer_ = base::MakeUnique<IntTestWebStateObserver>(web_state());
95 observer_->ExpectPageLoad(url); 97 observer_->ExpectPageLoad(url);
96 block(); 98 block();
97 base::test::ios::WaitUntilCondition(^bool { 99 base::test::ios::WaitUntilCondition(^bool {
98 return observer_->IsExpectedPageLoaded(); 100 return observer_->IsExpectedPageLoaded();
99 }); 101 });
100 } 102 }
101 103
102 void WebIntTest::LoadUrl(const GURL& url) { 104 void WebIntTest::LoadUrl(const GURL& url) {
103 ExecuteBlockAndWaitForLoad(url, ^{ 105 ExecuteBlockAndWaitForLoad(url, ^{
104 web::NavigationManager::WebLoadParams params(url); 106 web::NavigationManager::WebLoadParams params(url);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 NSInteger WebIntTest::GetIndexOfNavigationItem( 145 NSInteger WebIntTest::GetIndexOfNavigationItem(
144 const web::NavigationItem* item) { 146 const web::NavigationItem* item) {
145 for (NSInteger i = 0; i < navigation_manager()->GetItemCount(); ++i) { 147 for (NSInteger i = 0; i < navigation_manager()->GetItemCount(); ++i) {
146 if (navigation_manager()->GetItemAtIndex(i) == item) 148 if (navigation_manager()->GetItemAtIndex(i) == item)
147 return i; 149 return i;
148 } 150 }
149 return NSNotFound; 151 return NSNotFound;
150 } 152 }
151 153
152 } // namespace web 154 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/test/web_int_test.h ('k') | ios/web/web_state/http_auth_inttest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698