| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #import "ios/web/web_state/web_state_impl.h" | 47 #import "ios/web/web_state/web_state_impl.h" |
| 48 #import "net/base/mac/url_conversions.h" | 48 #import "net/base/mac/url_conversions.h" |
| 49 #include "net/http/http_response_headers.h" | 49 #include "net/http/http_response_headers.h" |
| 50 #include "testing/gtest/include/gtest/gtest.h" | 50 #include "testing/gtest/include/gtest/gtest.h" |
| 51 #include "testing/gtest_mac.h" | 51 #include "testing/gtest_mac.h" |
| 52 #import "third_party/ocmock/OCMock/OCMock.h" | 52 #import "third_party/ocmock/OCMock/OCMock.h" |
| 53 | 53 |
| 54 using web::WebStateImpl; | 54 using web::WebStateImpl; |
| 55 | 55 |
| 56 static const char kNewTabUrl[] = "chrome://newtab/"; | 56 static const char kNewTabUrl[] = "chrome://newtab/"; |
| 57 static NSString* const kNewTabTitle = @"New Tab"; | |
| 58 static const char kGoogleUserUrl[] = "http://google.com"; | 57 static const char kGoogleUserUrl[] = "http://google.com"; |
| 59 static const char kGoogleRedirectUrl[] = "http://www.google.fr/"; | 58 static const char kGoogleRedirectUrl[] = "http://www.google.fr/"; |
| 60 static NSString* const kGoogleTitle = @"Google"; | 59 static NSString* const kGoogleTitle = @"Google"; |
| 61 static const char kOtherUserUrl[] = "http://other.com"; | 60 static const char kOtherUserUrl[] = "http://other.com"; |
| 62 static const char kOtherRedirectUrl[] = "http://other.fr/"; | 61 static const char kOtherRedirectUrl[] = "http://other.fr/"; |
| 63 static NSString* const kOtherTitle = @"Other"; | 62 static NSString* const kOtherTitle = @"Other"; |
| 64 const char kContentDispositionWithFilename[] = | 63 const char kContentDispositionWithFilename[] = |
| 65 "attachment; filename=\"suggested_filename.pdf\""; | 64 "attachment; filename=\"suggested_filename.pdf\""; |
| 66 const char kContentDispositionWithoutFilename[] = | 65 const char kContentDispositionWithoutFilename[] = |
| 67 "attachment; parameter=parameter_value"; | 66 "attachment; parameter=parameter_value"; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 web::NavigationInitiationType::RENDERER_INITIATED); | 239 web::NavigationInitiationType::RENDERER_INITIATED); |
| 241 | 240 |
| 242 web_state_impl_->OnProvisionalNavigationStarted(redirectUrl); | 241 web_state_impl_->OnProvisionalNavigationStarted(redirectUrl); |
| 243 [[tab_ navigationManager]->GetSessionController() commitPendingItem]; | 242 [[tab_ navigationManager]->GetSessionController() commitPendingItem]; |
| 244 [[tab_ webController] webStateImpl]->OnNavigationCommitted(redirectUrl); | 243 [[tab_ webController] webStateImpl]->OnNavigationCommitted(redirectUrl); |
| 245 [tab_ webDidStartLoadingURL:redirectUrl shouldUpdateHistory:YES]; | 244 [tab_ webDidStartLoadingURL:redirectUrl shouldUpdateHistory:YES]; |
| 246 | 245 |
| 247 base::string16 new_title = base::SysNSStringToUTF16(title); | 246 base::string16 new_title = base::SysNSStringToUTF16(title); |
| 248 [tab_ navigationManager]->GetLastCommittedItem()->SetTitle(new_title); | 247 [tab_ navigationManager]->GetLastCommittedItem()->SetTitle(new_title); |
| 249 | 248 |
| 250 [tab_ webController:mock_web_controller_ titleDidChange:title]; | 249 web_state_impl_->OnTitleChanged(); |
| 251 [[[(id)mock_web_controller_ expect] | 250 [[[(id)mock_web_controller_ expect] |
| 252 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase]; | 251 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase]; |
| 253 web_state_impl_->OnPageLoaded(redirectUrl, true); | 252 web_state_impl_->OnPageLoaded(redirectUrl, true); |
| 254 } | 253 } |
| 255 | 254 |
| 256 void BrowseToNewTab() { | 255 void BrowseToNewTab() { |
| 257 DCHECK_EQ(tab_.get().webState, web_state_impl_); | 256 DCHECK_EQ(tab_.get().webState, web_state_impl_); |
| 258 const GURL url(kNewTabUrl); | 257 const GURL url(kNewTabUrl); |
| 259 // TODO(crbug.com/661992): This will not work with a mock CRWWebController. | 258 // TODO(crbug.com/661992): This will not work with a mock CRWWebController. |
| 260 // The only test that uses it is currently disabled. | 259 // The only test that uses it is currently disabled. |
| 261 web::NavigationManager::WebLoadParams params(url); | 260 web::NavigationManager::WebLoadParams params(url); |
| 262 params.transition_type = ui::PAGE_TRANSITION_TYPED; | 261 params.transition_type = ui::PAGE_TRANSITION_TYPED; |
| 263 [[tab_ webController] loadWithParams:params]; | 262 [[tab_ webController] loadWithParams:params]; |
| 264 [[[(id)mock_web_controller_ expect] | 263 [[[(id)mock_web_controller_ expect] |
| 265 andReturnValue:OCMOCK_VALUE(kPageLoading)] loadPhase]; | 264 andReturnValue:OCMOCK_VALUE(kPageLoading)] loadPhase]; |
| 266 [tab_ webDidStartLoadingURL:url shouldUpdateHistory:YES]; | 265 [tab_ webDidStartLoadingURL:url shouldUpdateHistory:YES]; |
| 267 [[[(id)mock_web_controller_ expect] | 266 [[[(id)mock_web_controller_ expect] |
| 268 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase]; | 267 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase]; |
| 269 web_state_impl_->OnPageLoaded(url, true); | 268 web_state_impl_->OnPageLoaded(url, true); |
| 270 [tab_ webController:mock_web_controller_ titleDidChange:kNewTabTitle]; | 269 web_state_impl_->OnTitleChanged(); |
| 271 } | 270 } |
| 272 | 271 |
| 273 void QueryAllHistory(history::QueryResults* results) { | 272 void QueryAllHistory(history::QueryResults* results) { |
| 274 base::CancelableTaskTracker tracker; | 273 base::CancelableTaskTracker tracker; |
| 275 base::RunLoop run_loop; | 274 base::RunLoop run_loop; |
| 276 scoped_refptr<HistoryQueryResultsObserver> observer( | 275 scoped_refptr<HistoryQueryResultsObserver> observer( |
| 277 new HistoryQueryResultsObserver(&run_loop)); | 276 new HistoryQueryResultsObserver(&run_loop)); |
| 278 history_service_->QueryHistory( | 277 history_service_->QueryHistory( |
| 279 base::string16(), history::QueryOptions(), | 278 base::string16(), history::QueryOptions(), |
| 280 base::Bind(&HistoryQueryResultsObserver::ProcessResults, observer), | 279 base::Bind(&HistoryQueryResultsObserver::ProcessResults, observer), |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 [[FakeNativeAppMetadata alloc] init]); | 551 [[FakeNativeAppMetadata alloc] init]); |
| 553 | 552 |
| 554 // Turn auto open on. | 553 // Turn auto open on. |
| 555 [metadata setShouldAutoOpenLinks:YES]; | 554 [metadata setShouldAutoOpenLinks:YES]; |
| 556 int expectedCallCount = 2; | 555 int expectedCallCount = 2; |
| 557 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); | 556 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); |
| 558 EXPECT_FALSE([metadata shouldAutoOpenLinks]); | 557 EXPECT_FALSE([metadata shouldAutoOpenLinks]); |
| 559 } | 558 } |
| 560 | 559 |
| 561 } // namespace | 560 } // namespace |
| OLD | NEW |