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

Side by Side Diff: ios/web/web_state/ui/crw_web_controller_unittest.mm

Issue 2698773002: [iOS] Refactoring web CRWSessionController user agent code. (Closed)
Patch Set: Fix unit tests and rebase 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
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/web_state/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 initWithRepresentedObject:originalMockDelegate]); 211 initWithRepresentedObject:originalMockDelegate]);
212 [web_controller() setDelegate:mockDelegate_]; 212 [web_controller() setDelegate:mockDelegate_];
213 base::scoped_nsobject<TestWebViewContentView> webViewContentView( 213 base::scoped_nsobject<TestWebViewContentView> webViewContentView(
214 [[TestWebViewContentView alloc] initWithMockWebView:mockWebView_ 214 [[TestWebViewContentView alloc] initWithMockWebView:mockWebView_
215 scrollView:mockScrollView_]); 215 scrollView:mockScrollView_]);
216 [web_controller() injectWebViewContentView:webViewContentView]; 216 [web_controller() injectWebViewContentView:webViewContentView];
217 217
218 NavigationManagerImpl& navigationManager = 218 NavigationManagerImpl& navigationManager =
219 [web_controller() webStateImpl]->GetNavigationManagerImpl(); 219 [web_controller() webStateImpl]->GetNavigationManagerImpl();
220 navigationManager.InitializeSession(@"name", nil, NO, 0); 220 navigationManager.InitializeSession(@"name", nil, NO, 0);
221 [navigationManager.GetSessionController() 221 navigationManager.AddPendingItem(
222 addPendingItem:GURL("http://www.google.com/?q=foo#bar") 222 GURL("http://www.google.com/?q=foo#bar"), web::Referrer(),
223 referrer:web::Referrer() 223 ui::PAGE_TRANSITION_TYPED,
224 transition:ui::PAGE_TRANSITION_TYPED 224 web::NavigationInitiationType::USER_INITIATED);
225 rendererInitiated:NO];
226 } 225 }
227 226
228 void TearDown() override { 227 void TearDown() override {
229 EXPECT_OCMOCK_VERIFY(mockDelegate_); 228 EXPECT_OCMOCK_VERIFY(mockDelegate_);
230 EXPECT_OCMOCK_VERIFY(mockChildWebController_); 229 EXPECT_OCMOCK_VERIFY(mockChildWebController_);
231 EXPECT_OCMOCK_VERIFY(mockWebView_); 230 EXPECT_OCMOCK_VERIFY(mockWebView_);
232 [web_controller() resetInjectedWebViewContentView]; 231 [web_controller() resetInjectedWebViewContentView];
233 [web_controller() setDelegate:nil]; 232 [web_controller() setDelegate:nil];
234 web::WebTestWithWebController::TearDown(); 233 web::WebTestWithWebController::TearDown();
235 } 234 }
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 void SetUp() override { 802 void SetUp() override {
804 web::WebTestWithWebController::SetUp(); 803 web::WebTestWithWebController::SetUp();
805 mock_native_provider_.reset([[TestNativeContentProvider alloc] init]); 804 mock_native_provider_.reset([[TestNativeContentProvider alloc] init]);
806 [web_controller() setNativeProvider:mock_native_provider_]; 805 [web_controller() setNativeProvider:mock_native_provider_];
807 } 806 }
808 807
809 void Load(const GURL& URL) { 808 void Load(const GURL& URL) {
810 NavigationManagerImpl& navigation_manager = 809 NavigationManagerImpl& navigation_manager =
811 [web_controller() webStateImpl]->GetNavigationManagerImpl(); 810 [web_controller() webStateImpl]->GetNavigationManagerImpl();
812 navigation_manager.InitializeSession(@"name", nil, NO, 0); 811 navigation_manager.InitializeSession(@"name", nil, NO, 0);
813 [navigation_manager.GetSessionController() 812 navigation_manager.AddPendingItem(
814 addPendingItem:URL 813 URL, web::Referrer(), ui::PAGE_TRANSITION_TYPED,
815 referrer:web::Referrer() 814 web::NavigationInitiationType::USER_INITIATED);
816 transition:ui::PAGE_TRANSITION_TYPED
817 rendererInitiated:NO];
818 [web_controller() loadCurrentURL]; 815 [web_controller() loadCurrentURL];
819 } 816 }
820 817
821 base::scoped_nsobject<TestNativeContentProvider> mock_native_provider_; 818 base::scoped_nsobject<TestNativeContentProvider> mock_native_provider_;
822 }; 819 };
823 820
824 // Tests WebState and NavigationManager correctly return native content URL. 821 // Tests WebState and NavigationManager correctly return native content URL.
825 TEST_F(CRWWebControllerNativeContentTest, NativeContentURL) { 822 TEST_F(CRWWebControllerNativeContentTest, NativeContentURL) {
826 GURL url_to_load(kTestAppSpecificURL); 823 GURL url_to_load(kTestAppSpecificURL);
827 base::scoped_nsobject<TestNativeContent> content( 824 base::scoped_nsobject<TestNativeContent> content(
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 }; 1052 };
1056 1053
1057 RenderProcessGoneObserver observer(web_state()); 1054 RenderProcessGoneObserver observer(web_state());
1058 web::SimulateWKWebViewCrash(webView_); 1055 web::SimulateWKWebViewCrash(webView_);
1059 observer.WaitForRenderProcessGone(); 1056 observer.WaitForRenderProcessGone();
1060 1057
1061 EXPECT_FALSE([web_controller() isViewAlive]); 1058 EXPECT_FALSE([web_controller() isViewAlive]);
1062 }; 1059 };
1063 1060
1064 } // namespace 1061 } // namespace
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698