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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 navigation_manager()->AddPendingItem( | 580 navigation_manager()->AddPendingItem( |
581 GURL("http://www.3.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | 581 GURL("http://www.3.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, |
582 web::NavigationInitiationType::USER_INITIATED); | 582 web::NavigationInitiationType::USER_INITIATED); |
583 [session_controller() commitPendingItem]; | 583 [session_controller() commitPendingItem]; |
584 web::NavigationItem* item3 = navigation_manager()->GetLastCommittedItem(); | 584 web::NavigationItem* item3 = navigation_manager()->GetLastCommittedItem(); |
585 | 585 |
586 // Verify that |item2|'s UserAgentType is propagated to |item3|. | 586 // Verify that |item2|'s UserAgentType is propagated to |item3|. |
587 EXPECT_EQ(item2->GetUserAgentType(), item3->GetUserAgentType()); | 587 EXPECT_EQ(item2->GetUserAgentType(), item3->GetUserAgentType()); |
588 } | 588 } |
589 | 589 |
| 590 // Tests that adding transient item for a pending item with mobile user agent |
| 591 // type results in a transient item with mobile user agent type. |
| 592 TEST_F(NavigationManagerTest, AddTransientItemForMobilePendingItem) { |
| 593 navigation_manager()->AddPendingItem( |
| 594 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, |
| 595 web::NavigationInitiationType::USER_INITIATED); |
| 596 ASSERT_TRUE(navigation_manager()->GetPendingItem()); |
| 597 navigation_manager()->GetPendingItem()->SetUserAgentType( |
| 598 UserAgentType::MOBILE); |
| 599 |
| 600 navigation_manager()->AddTransientItem(GURL("http://www.url.com")); |
| 601 ASSERT_TRUE(navigation_manager()->GetTransientItem()); |
| 602 EXPECT_EQ(UserAgentType::MOBILE, |
| 603 navigation_manager()->GetTransientItem()->GetUserAgentType()); |
| 604 EXPECT_EQ(UserAgentType::MOBILE, |
| 605 navigation_manager()->GetPendingItem()->GetUserAgentType()); |
| 606 } |
| 607 |
| 608 // Tests that adding transient item for a pending item with desktop user agent |
| 609 // type results in a transient item with desktop user agent type. |
| 610 TEST_F(NavigationManagerTest, AddTransientItemForDesktopPendingItem) { |
| 611 navigation_manager()->AddPendingItem( |
| 612 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, |
| 613 web::NavigationInitiationType::USER_INITIATED); |
| 614 ASSERT_TRUE(navigation_manager()->GetPendingItem()); |
| 615 navigation_manager()->GetPendingItem()->SetUserAgentType( |
| 616 UserAgentType::DESKTOP); |
| 617 |
| 618 navigation_manager()->AddTransientItem(GURL("http://www.url.com")); |
| 619 ASSERT_TRUE(navigation_manager()->GetTransientItem()); |
| 620 EXPECT_EQ(UserAgentType::DESKTOP, |
| 621 navigation_manager()->GetTransientItem()->GetUserAgentType()); |
| 622 EXPECT_EQ(UserAgentType::DESKTOP, |
| 623 navigation_manager()->GetPendingItem()->GetUserAgentType()); |
| 624 } |
| 625 |
590 // Tests that calling |Reload| with web::ReloadType::NORMAL is no-op when there | 626 // Tests that calling |Reload| with web::ReloadType::NORMAL is no-op when there |
591 // are no transient, pending and committed items. | 627 // are no transient, pending and committed items. |
592 TEST_F(NavigationManagerTest, ReloadEmptyWithNormalType) { | 628 TEST_F(NavigationManagerTest, ReloadEmptyWithNormalType) { |
593 ASSERT_FALSE(navigation_manager()->GetTransientItem()); | 629 ASSERT_FALSE(navigation_manager()->GetTransientItem()); |
594 ASSERT_FALSE(navigation_manager()->GetPendingItem()); | 630 ASSERT_FALSE(navigation_manager()->GetPendingItem()); |
595 ASSERT_FALSE(navigation_manager()->GetLastCommittedItem()); | 631 ASSERT_FALSE(navigation_manager()->GetLastCommittedItem()); |
596 | 632 |
597 navigation_manager()->Reload(web::ReloadType::NORMAL, | 633 navigation_manager()->Reload(web::ReloadType::NORMAL, |
598 false /* check_for_repost */); | 634 false /* check_for_repost */); |
599 EXPECT_FALSE(navigation_manager_delegate().reload_called()); | 635 EXPECT_FALSE(navigation_manager_delegate().reload_called()); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 navigation_manager()->Reload(web::ReloadType::ORIGINAL_REQUEST_URL, | 844 navigation_manager()->Reload(web::ReloadType::ORIGINAL_REQUEST_URL, |
809 false /* check_for_repost */); | 845 false /* check_for_repost */); |
810 EXPECT_TRUE(navigation_manager_delegate().reload_called()); | 846 EXPECT_TRUE(navigation_manager_delegate().reload_called()); |
811 | 847 |
812 ASSERT_TRUE(navigation_manager()->GetLastCommittedItem()); | 848 ASSERT_TRUE(navigation_manager()->GetLastCommittedItem()); |
813 EXPECT_EQ(expected_original_url, | 849 EXPECT_EQ(expected_original_url, |
814 navigation_manager()->GetLastCommittedItem()->GetURL()); | 850 navigation_manager()->GetLastCommittedItem()->GetURL()); |
815 } | 851 } |
816 | 852 |
817 } // namespace web | 853 } // namespace web |
OLD | NEW |