OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/web_state_impl.h" | 5 #import "ios/web/web_state/web_state_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/base64.h" | 11 #include "base/base64.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #import "base/mac/bind_objc_block.h" | 14 #import "base/mac/bind_objc_block.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #import "base/test/ios/wait_util.h" | 16 #import "base/test/ios/wait_util.h" |
17 #import "ios/web/public/java_script_dialog_presenter.h" | 17 #import "ios/web/public/java_script_dialog_presenter.h" |
18 #include "ios/web/public/load_committed_details.h" | 18 #include "ios/web/public/load_committed_details.h" |
19 #include "ios/web/public/test/fakes/test_browser_state.h" | 19 #include "ios/web/public/test/fakes/test_browser_state.h" |
20 #import "ios/web/public/test/fakes/test_web_state_delegate.h" | 20 #import "ios/web/public/test/fakes/test_web_state_delegate.h" |
21 #import "ios/web/public/test/fakes/test_web_state_observer.h" | 21 #import "ios/web/public/test/fakes/test_web_state_observer.h" |
22 #include "ios/web/public/test/web_test.h" | 22 #include "ios/web/public/test/web_test.h" |
23 #import "ios/web/public/web_state/context_menu_params.h" | 23 #import "ios/web/public/web_state/context_menu_params.h" |
24 #include "ios/web/public/web_state/global_web_state_observer.h" | 24 #include "ios/web/public/web_state/global_web_state_observer.h" |
25 #include "ios/web/public/web_state/navigation_context.h" | |
26 #import "ios/web/public/web_state/web_state_delegate.h" | 25 #import "ios/web/public/web_state/web_state_delegate.h" |
27 #include "ios/web/public/web_state/web_state_observer.h" | 26 #include "ios/web/public/web_state/web_state_observer.h" |
28 #import "ios/web/public/web_state/web_state_policy_decider.h" | 27 #import "ios/web/public/web_state/web_state_policy_decider.h" |
29 #include "ios/web/web_state/global_web_state_event_tracker.h" | 28 #include "ios/web/web_state/global_web_state_event_tracker.h" |
30 #include "ios/web/web_state/navigation_context_impl.h" | 29 #import "ios/web/web_state/navigation_context_impl.h" |
31 #import "ios/web/web_state/ui/crw_web_controller.h" | 30 #import "ios/web/web_state/ui/crw_web_controller.h" |
32 #include "net/http/http_response_headers.h" | 31 #include "net/http/http_response_headers.h" |
33 #include "net/http/http_util.h" | 32 #include "net/http/http_util.h" |
34 #include "testing/gmock/include/gmock/gmock.h" | 33 #include "testing/gmock/include/gmock/gmock.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
36 #import "testing/gtest_mac.h" | 35 #import "testing/gtest_mac.h" |
37 #include "url/gurl.h" | 36 #include "url/gurl.h" |
38 | 37 |
39 using testing::_; | 38 using testing::_; |
40 using testing::Assign; | 39 using testing::Assign; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 std::unique_ptr<web::NavigationContext> context = | 352 std::unique_ptr<web::NavigationContext> context = |
354 NavigationContextImpl::CreateNavigationContext(web_state_.get(), url); | 353 NavigationContextImpl::CreateNavigationContext(web_state_.get(), url); |
355 web_state_->OnNavigationFinished(context.get()); | 354 web_state_->OnNavigationFinished(context.get()); |
356 ASSERT_TRUE(observer->did_finish_navigation_info()); | 355 ASSERT_TRUE(observer->did_finish_navigation_info()); |
357 EXPECT_EQ(web_state_.get(), | 356 EXPECT_EQ(web_state_.get(), |
358 observer->did_finish_navigation_info()->web_state); | 357 observer->did_finish_navigation_info()->web_state); |
359 NavigationContext* actual_context = | 358 NavigationContext* actual_context = |
360 observer->did_finish_navigation_info()->context.get(); | 359 observer->did_finish_navigation_info()->context.get(); |
361 EXPECT_EQ(context->GetUrl(), actual_context->GetUrl()); | 360 EXPECT_EQ(context->GetUrl(), actual_context->GetUrl()); |
362 EXPECT_FALSE(actual_context->IsSameDocument()); | 361 EXPECT_FALSE(actual_context->IsSameDocument()); |
363 EXPECT_FALSE(actual_context->IsErrorPage()); | 362 EXPECT_FALSE(actual_context->GetError()); |
364 EXPECT_FALSE(actual_context->GetResponseHeaders()); | 363 EXPECT_FALSE(actual_context->GetResponseHeaders()); |
365 | 364 |
366 // Test that DidStartNavigation() is called. | 365 // Test that DidStartNavigation() is called. |
367 ASSERT_FALSE(observer->did_start_navigation_info()); | 366 ASSERT_FALSE(observer->did_start_navigation_info()); |
368 web_state_->OnNavigationStarted(context.get()); | 367 web_state_->OnNavigationStarted(context.get()); |
369 ASSERT_TRUE(observer->did_start_navigation_info()); | 368 ASSERT_TRUE(observer->did_start_navigation_info()); |
370 EXPECT_EQ(web_state_.get(), observer->did_start_navigation_info()->web_state); | 369 EXPECT_EQ(web_state_.get(), observer->did_start_navigation_info()->web_state); |
371 actual_context = observer->did_start_navigation_info()->context.get(); | 370 actual_context = observer->did_start_navigation_info()->context.get(); |
372 EXPECT_EQ(context->GetUrl(), actual_context->GetUrl()); | 371 EXPECT_EQ(context->GetUrl(), actual_context->GetUrl()); |
373 EXPECT_FALSE(actual_context->IsSameDocument()); | 372 EXPECT_FALSE(actual_context->IsSameDocument()); |
374 EXPECT_FALSE(actual_context->IsErrorPage()); | 373 EXPECT_FALSE(actual_context->GetError()); |
375 EXPECT_FALSE(actual_context->GetResponseHeaders()); | 374 EXPECT_FALSE(actual_context->GetResponseHeaders()); |
376 | 375 |
377 // Test that NavigationItemsPruned() is called. | 376 // Test that NavigationItemsPruned() is called. |
378 ASSERT_FALSE(observer->navigation_items_pruned_info()); | 377 ASSERT_FALSE(observer->navigation_items_pruned_info()); |
379 web_state_->OnNavigationItemsPruned(1); | 378 web_state_->OnNavigationItemsPruned(1); |
380 ASSERT_TRUE(observer->navigation_items_pruned_info()); | 379 ASSERT_TRUE(observer->navigation_items_pruned_info()); |
381 EXPECT_EQ(web_state_.get(), | 380 EXPECT_EQ(web_state_.get(), |
382 observer->navigation_items_pruned_info()->web_state); | 381 observer->navigation_items_pruned_info()->web_state); |
383 | 382 |
384 // Test that NavigationItemChanged() is called. | 383 // Test that NavigationItemChanged() is called. |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 // Set |created_with_opener| to true and verify that HasOpener() returns true. | 685 // Set |created_with_opener| to true and verify that HasOpener() returns true. |
687 WebState::CreateParams params_with_opener = | 686 WebState::CreateParams params_with_opener = |
688 WebState::CreateParams(GetBrowserState()); | 687 WebState::CreateParams(GetBrowserState()); |
689 params_with_opener.created_with_opener = true; | 688 params_with_opener.created_with_opener = true; |
690 std::unique_ptr<WebState> web_state_with_opener = | 689 std::unique_ptr<WebState> web_state_with_opener = |
691 WebState::Create(params_with_opener); | 690 WebState::Create(params_with_opener); |
692 EXPECT_TRUE(web_state_with_opener->HasOpener()); | 691 EXPECT_TRUE(web_state_with_opener->HasOpener()); |
693 } | 692 } |
694 | 693 |
695 } // namespace web | 694 } // namespace web |
OLD | NEW |