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/navigation/navigation_manager_impl.h" | 5 #import "ios/web/navigation/navigation_manager_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 #import "ios/web/navigation/crw_session_controller+private_constructors.h" | 9 #import "ios/web/navigation/crw_session_controller+private_constructors.h" |
10 #import "ios/web/navigation/navigation_manager_delegate.h" | 10 #import "ios/web/navigation/navigation_manager_delegate.h" |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 GURL("http://www.3.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | 674 GURL("http://www.3.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, |
675 web::NavigationInitiationType::USER_INITIATED, | 675 web::NavigationInitiationType::USER_INITIATED, |
676 web::NavigationManager::UserAgentOverrideOption::INHERIT); | 676 web::NavigationManager::UserAgentOverrideOption::INHERIT); |
677 [session_controller() commitPendingItem]; | 677 [session_controller() commitPendingItem]; |
678 web::NavigationItem* item3 = navigation_manager()->GetLastCommittedItem(); | 678 web::NavigationItem* item3 = navigation_manager()->GetLastCommittedItem(); |
679 | 679 |
680 // Verify that |item2|'s UserAgentType is propagated to |item3|. | 680 // Verify that |item2|'s UserAgentType is propagated to |item3|. |
681 EXPECT_EQ(item2->GetUserAgentType(), item3->GetUserAgentType()); | 681 EXPECT_EQ(item2->GetUserAgentType(), item3->GetUserAgentType()); |
682 } | 682 } |
683 | 683 |
684 // Tests that adding transient item for a pending item with mobile user agent | |
685 // type results in a transient item with mobile user agent type. | |
686 TEST_F(NavigationManagerTest, AddTransientItemForMobilePendingItem) { | |
687 navigation_manager()->AddPendingItem( | |
688 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | |
689 web::NavigationInitiationType::USER_INITIATED, | |
690 web::NavigationManager::UserAgentOverrideOption::INHERIT); | |
691 ASSERT_TRUE(navigation_manager()->GetPendingItem()); | |
692 navigation_manager()->GetPendingItem()->SetUserAgentType( | |
693 UserAgentType::MOBILE); | |
694 | |
695 navigation_manager()->AddTransientItem(GURL("http://www.url.com")); | |
696 ASSERT_TRUE(navigation_manager()->GetTransientItem()); | |
697 EXPECT_EQ(UserAgentType::MOBILE, | |
698 navigation_manager()->GetTransientItem()->GetUserAgentType()); | |
699 EXPECT_EQ(UserAgentType::MOBILE, | |
700 navigation_manager()->GetPendingItem()->GetUserAgentType()); | |
701 } | |
702 | |
703 // Tests that adding transient item for a pending item with desktop user agent | |
704 // type results in a transient item with desktop user agent type. | |
705 TEST_F(NavigationManagerTest, AddTransientItemForDesktopPendingItem) { | |
706 navigation_manager()->AddPendingItem( | |
707 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | |
708 web::NavigationInitiationType::USER_INITIATED, | |
709 web::NavigationManager::UserAgentOverrideOption::INHERIT); | |
710 ASSERT_TRUE(navigation_manager()->GetPendingItem()); | |
711 navigation_manager()->GetPendingItem()->SetUserAgentType( | |
712 UserAgentType::DESKTOP); | |
713 | |
714 navigation_manager()->AddTransientItem(GURL("http://www.url.com")); | |
715 ASSERT_TRUE(navigation_manager()->GetTransientItem()); | |
716 EXPECT_EQ(UserAgentType::DESKTOP, | |
717 navigation_manager()->GetTransientItem()->GetUserAgentType()); | |
718 EXPECT_EQ(UserAgentType::DESKTOP, | |
719 navigation_manager()->GetPendingItem()->GetUserAgentType()); | |
720 } | |
721 | |
722 // Tests that calling |Reload| with web::ReloadType::NORMAL is no-op when there | 684 // Tests that calling |Reload| with web::ReloadType::NORMAL is no-op when there |
723 // are no transient, pending and committed items. | 685 // are no transient, pending and committed items. |
724 TEST_F(NavigationManagerTest, ReloadEmptyWithNormalType) { | 686 TEST_F(NavigationManagerTest, ReloadEmptyWithNormalType) { |
725 ASSERT_FALSE(navigation_manager()->GetTransientItem()); | 687 ASSERT_FALSE(navigation_manager()->GetTransientItem()); |
726 ASSERT_FALSE(navigation_manager()->GetPendingItem()); | 688 ASSERT_FALSE(navigation_manager()->GetPendingItem()); |
727 ASSERT_FALSE(navigation_manager()->GetLastCommittedItem()); | 689 ASSERT_FALSE(navigation_manager()->GetLastCommittedItem()); |
728 | 690 |
729 navigation_manager()->Reload(web::ReloadType::NORMAL, | 691 navigation_manager()->Reload(web::ReloadType::NORMAL, |
730 false /* check_for_repost */); | 692 false /* check_for_repost */); |
731 EXPECT_FALSE(navigation_manager_delegate().reload_called()); | 693 EXPECT_FALSE(navigation_manager_delegate().reload_called()); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 navigation_manager()->Reload(web::ReloadType::ORIGINAL_REQUEST_URL, | 916 navigation_manager()->Reload(web::ReloadType::ORIGINAL_REQUEST_URL, |
955 false /* check_for_repost */); | 917 false /* check_for_repost */); |
956 EXPECT_TRUE(navigation_manager_delegate().reload_called()); | 918 EXPECT_TRUE(navigation_manager_delegate().reload_called()); |
957 | 919 |
958 ASSERT_TRUE(navigation_manager()->GetLastCommittedItem()); | 920 ASSERT_TRUE(navigation_manager()->GetLastCommittedItem()); |
959 EXPECT_EQ(expected_original_url, | 921 EXPECT_EQ(expected_original_url, |
960 navigation_manager()->GetLastCommittedItem()->GetURL()); | 922 navigation_manager()->GetLastCommittedItem()->GetURL()); |
961 } | 923 } |
962 | 924 |
963 } // namespace web | 925 } // namespace web |
OLD | NEW |