Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: ios/web/navigation/navigation_manager_impl_unittest.mm

Issue 2741413007: Refactoring Reload in NavigationManager and CRWWebController. (Closed)
Patch Set: fixed more check_for_repost errors Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "ios/web/public/navigation_item.h" 11 #include "ios/web/public/navigation_item.h"
12 #include "ios/web/public/test/fakes/test_browser_state.h" 12 #include "ios/web/public/test/fakes/test_browser_state.h"
13 #include "ios/web/test/test_url_constants.h" 13 #include "ios/web/test/test_url_constants.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "testing/platform_test.h" 15 #include "testing/platform_test.h"
16 16
17 namespace web { 17 namespace web {
18 namespace { 18 namespace {
19 // Stub class for NavigationManagerDelegate. 19 // Stub class for NavigationManagerDelegate.
20 class TestNavigationManagerDelegate : public NavigationManagerDelegate { 20 class TestNavigationManagerDelegate : public NavigationManagerDelegate {
21 void GoToIndex(int index) override {} 21 void GoToIndex(int index) override {}
22 void LoadURLWithParams(const NavigationManager::WebLoadParams&) override {} 22 void LoadURLWithParams(const NavigationManager::WebLoadParams&) override {}
23 void Reload() override {}
23 void OnNavigationItemsPruned(size_t pruned_item_count) override {} 24 void OnNavigationItemsPruned(size_t pruned_item_count) override {}
24 void OnNavigationItemChanged() override{}; 25 void OnNavigationItemChanged() override{};
25 void OnNavigationItemCommitted(const LoadCommittedDetails&) override {} 26 void OnNavigationItemCommitted(const LoadCommittedDetails&) override {}
26 WebState* GetWebState() override { return nullptr; } 27 WebState* GetWebState() override { return nullptr; }
27 }; 28 };
28 } // namespace 29 } // namespace
29 30
30 // Test fixture for NavigationManagerImpl testing. 31 // Test fixture for NavigationManagerImpl testing.
31 class NavigationManagerTest : public PlatformTest { 32 class NavigationManagerTest : public PlatformTest {
32 protected: 33 protected:
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 navigation_manager()->AddPendingItem( 592 navigation_manager()->AddPendingItem(
592 GURL("http://www.3.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, 593 GURL("http://www.3.com"), Referrer(), ui::PAGE_TRANSITION_TYPED,
593 web::NavigationInitiationType::USER_INITIATED); 594 web::NavigationInitiationType::USER_INITIATED);
594 [session_controller() commitPendingItem]; 595 [session_controller() commitPendingItem];
595 web::NavigationItem* item3 = navigation_manager()->GetLastCommittedItem(); 596 web::NavigationItem* item3 = navigation_manager()->GetLastCommittedItem();
596 597
597 // Verify that |item2|'s UserAgentType is propagated to |item3|. 598 // Verify that |item2|'s UserAgentType is propagated to |item3|.
598 EXPECT_EQ(item2->GetUserAgentType(), item3->GetUserAgentType()); 599 EXPECT_EQ(item2->GetUserAgentType(), item3->GetUserAgentType());
599 } 600 }
600 601
602 // Tests that calling |Reload| on NavigationManager leaves the Url of the
603 // visible item unchanged.
604 TEST_F(NavigationManagerTest, ReloadWithNormalReloadType) {
605 navigation_manager()->AddPendingItem(
606 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED,
607 web::NavigationInitiationType::USER_INITIATED);
608 ASSERT_TRUE(navigation_manager()->GetVisibleItem());
609
610 GURL url_before_reload = navigation_manager()->GetVisibleItem()->GetURL();
611 navigation_manager()->Reload(web::ReloadType::NORMAL,
612 false /* check_for_repost */);
613
614 EXPECT_EQ(url_before_reload,
615 navigation_manager()->GetVisibleItem()->GetURL());
616 }
617
601 } // namespace web 618 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698