| 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 <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 | 222 |
| 223 void TearDown() override { | 223 void TearDown() override { |
| 224 [tab_ close]; | 224 [tab_ close]; |
| 225 | 225 |
| 226 BlockCleanupTest::TearDown(); | 226 BlockCleanupTest::TearDown(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void BrowseTo(const GURL& userUrl, const GURL& redirectUrl, NSString* title) { | 229 void BrowseTo(const GURL& userUrl, const GURL& redirectUrl, NSString* title) { |
| 230 DCHECK_EQ(tab_.get().webState, web_state_impl_); | 230 DCHECK_EQ(tab_.get().webState, web_state_impl_); |
| 231 web::Referrer empty_referrer; | 231 |
| 232 [tab_ webWillAddPendingURL:userUrl transition:ui::PAGE_TRANSITION_TYPED]; | 232 [tab_ webWillAddPendingURL:userUrl transition:ui::PAGE_TRANSITION_TYPED]; |
| 233 web_state_impl_->OnProvisionalNavigationStarted(userUrl); | 233 web_state_impl_->OnProvisionalNavigationStarted(userUrl); |
| 234 [tab_ webWillAddPendingURL:redirectUrl | 234 [tab_ webWillAddPendingURL:redirectUrl |
| 235 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT]; | 235 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT]; |
| 236 [[tab_ navigationManager]->GetSessionController() | 236 |
| 237 addPendingItem:redirectUrl | 237 web::Referrer empty_referrer; |
| 238 referrer:empty_referrer | 238 [tab_ navigationManager]->AddPendingItem( |
| 239 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT | 239 redirectUrl, empty_referrer, ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 240 rendererInitiated:YES]; | 240 web::NavigationInitiationType::RENDERER_INITIATED); |
| 241 |
| 241 web_state_impl_->OnProvisionalNavigationStarted(redirectUrl); | 242 web_state_impl_->OnProvisionalNavigationStarted(redirectUrl); |
| 242 [[tab_ navigationManager]->GetSessionController() commitPendingItem]; | 243 [[tab_ navigationManager]->GetSessionController() commitPendingItem]; |
| 243 [[tab_ webController] webStateImpl]->OnNavigationCommitted(redirectUrl); | 244 [[tab_ webController] webStateImpl]->OnNavigationCommitted(redirectUrl); |
| 244 [tab_ webDidStartLoadingURL:redirectUrl shouldUpdateHistory:YES]; | 245 [tab_ webDidStartLoadingURL:redirectUrl shouldUpdateHistory:YES]; |
| 246 |
| 245 base::string16 new_title = base::SysNSStringToUTF16(title); | 247 base::string16 new_title = base::SysNSStringToUTF16(title); |
| 246 [tab_ navigationManager]->GetLastCommittedItem()->SetTitle(new_title); | 248 [tab_ navigationManager]->GetLastCommittedItem()->SetTitle(new_title); |
| 249 |
| 247 [tab_ webController:mock_web_controller_ titleDidChange:title]; | 250 [tab_ webController:mock_web_controller_ titleDidChange:title]; |
| 248 [[[(id)mock_web_controller_ expect] | 251 [[[(id)mock_web_controller_ expect] |
| 249 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase]; | 252 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase]; |
| 250 web_state_impl_->OnPageLoaded(redirectUrl, true); | 253 web_state_impl_->OnPageLoaded(redirectUrl, true); |
| 251 } | 254 } |
| 252 | 255 |
| 253 void BrowseToNewTab() { | 256 void BrowseToNewTab() { |
| 254 DCHECK_EQ(tab_.get().webState, web_state_impl_); | 257 DCHECK_EQ(tab_.get().webState, web_state_impl_); |
| 255 const GURL url(kNewTabUrl); | 258 const GURL url(kNewTabUrl); |
| 256 // TODO(crbug.com/661992): This will not work with a mock CRWWebController. | 259 // TODO(crbug.com/661992): This will not work with a mock CRWWebController. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 [[FakeNativeAppMetadata alloc] init]); | 552 [[FakeNativeAppMetadata alloc] init]); |
| 550 | 553 |
| 551 // Turn auto open on. | 554 // Turn auto open on. |
| 552 [metadata setShouldAutoOpenLinks:YES]; | 555 [metadata setShouldAutoOpenLinks:YES]; |
| 553 int expectedCallCount = 2; | 556 int expectedCallCount = 2; |
| 554 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); | 557 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); |
| 555 EXPECT_FALSE([metadata shouldAutoOpenLinks]); | 558 EXPECT_FALSE([metadata shouldAutoOpenLinks]); |
| 556 } | 559 } |
| 557 | 560 |
| 558 } // namespace | 561 } // namespace |
| OLD | NEW |