| OLD | NEW |
| 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 Loading... |
| 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(GURL("http://www.google.com/?q=foo#bar"), |
| 222 addPendingItem:GURL("http://www.google.com/?q=foo#bar") | 222 web::Referrer(), ui::PAGE_TRANSITION_TYPED, |
| 223 referrer:web::Referrer() | 223 web::ItemInitiationType::USER_INITIATED); |
| 224 transition:ui::PAGE_TRANSITION_TYPED | |
| 225 rendererInitiated:NO]; | |
| 226 } | 224 } |
| 227 | 225 |
| 228 void TearDown() override { | 226 void TearDown() override { |
| 229 EXPECT_OCMOCK_VERIFY(mockDelegate_); | 227 EXPECT_OCMOCK_VERIFY(mockDelegate_); |
| 230 EXPECT_OCMOCK_VERIFY(mockChildWebController_); | 228 EXPECT_OCMOCK_VERIFY(mockChildWebController_); |
| 231 EXPECT_OCMOCK_VERIFY(mockWebView_); | 229 EXPECT_OCMOCK_VERIFY(mockWebView_); |
| 232 [web_controller() resetInjectedWebViewContentView]; | 230 [web_controller() resetInjectedWebViewContentView]; |
| 233 [web_controller() setDelegate:nil]; | 231 [web_controller() setDelegate:nil]; |
| 234 web::WebTestWithWebController::TearDown(); | 232 web::WebTestWithWebController::TearDown(); |
| 235 } | 233 } |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 void SetUp() override { | 801 void SetUp() override { |
| 804 web::WebTestWithWebController::SetUp(); | 802 web::WebTestWithWebController::SetUp(); |
| 805 mock_native_provider_.reset([[TestNativeContentProvider alloc] init]); | 803 mock_native_provider_.reset([[TestNativeContentProvider alloc] init]); |
| 806 [web_controller() setNativeProvider:mock_native_provider_]; | 804 [web_controller() setNativeProvider:mock_native_provider_]; |
| 807 } | 805 } |
| 808 | 806 |
| 809 void Load(const GURL& URL) { | 807 void Load(const GURL& URL) { |
| 810 NavigationManagerImpl& navigation_manager = | 808 NavigationManagerImpl& navigation_manager = |
| 811 [web_controller() webStateImpl]->GetNavigationManagerImpl(); | 809 [web_controller() webStateImpl]->GetNavigationManagerImpl(); |
| 812 navigation_manager.InitializeSession(@"name", nil, NO, 0); | 810 navigation_manager.InitializeSession(@"name", nil, NO, 0); |
| 813 [navigation_manager.GetSessionController() | 811 navigation_manager.AddPendingItem(URL, web::Referrer(), |
| 814 addPendingItem:URL | 812 ui::PAGE_TRANSITION_TYPED, |
| 815 referrer:web::Referrer() | 813 web::ItemInitiationType::USER_INITIATED); |
| 816 transition:ui::PAGE_TRANSITION_TYPED | |
| 817 rendererInitiated:NO]; | |
| 818 [web_controller() loadCurrentURL]; | 814 [web_controller() loadCurrentURL]; |
| 819 } | 815 } |
| 820 | 816 |
| 821 base::scoped_nsobject<TestNativeContentProvider> mock_native_provider_; | 817 base::scoped_nsobject<TestNativeContentProvider> mock_native_provider_; |
| 822 }; | 818 }; |
| 823 | 819 |
| 824 // Tests WebState and NavigationManager correctly return native content URL. | 820 // Tests WebState and NavigationManager correctly return native content URL. |
| 825 TEST_F(CRWWebControllerNativeContentTest, NativeContentURL) { | 821 TEST_F(CRWWebControllerNativeContentTest, NativeContentURL) { |
| 826 GURL url_to_load(kTestAppSpecificURL); | 822 GURL url_to_load(kTestAppSpecificURL); |
| 827 base::scoped_nsobject<TestNativeContent> content( | 823 base::scoped_nsobject<TestNativeContent> content( |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 }; | 1051 }; |
| 1056 | 1052 |
| 1057 RenderProcessGoneObserver observer(web_state()); | 1053 RenderProcessGoneObserver observer(web_state()); |
| 1058 web::SimulateWKWebViewCrash(webView_); | 1054 web::SimulateWKWebViewCrash(webView_); |
| 1059 observer.WaitForRenderProcessGone(); | 1055 observer.WaitForRenderProcessGone(); |
| 1060 | 1056 |
| 1061 EXPECT_FALSE([web_controller() isViewAlive]); | 1057 EXPECT_FALSE([web_controller() isViewAlive]); |
| 1062 }; | 1058 }; |
| 1063 | 1059 |
| 1064 } // namespace | 1060 } // namespace |
| OLD | NEW |