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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 148083013: Move browser initiated navigation from RenderViewHost to RenderFrameHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another one bites the dust. Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "base/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "content/browser/frame_host/navigation_controller_impl.h" 6 #include "content/browser/frame_host/navigation_controller_impl.h"
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/frame_host/navigator.h" 8 #include "content/browser/frame_host/navigator.h"
9 #include "content/browser/frame_host/render_frame_host_manager.h" 9 #include "content/browser/frame_host/render_frame_host_manager.h"
10 #include "content/browser/site_instance_impl.h" 10 #include "content/browser/site_instance_impl.h"
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 EXPECT_NE(host2, host); 748 EXPECT_NE(host2, host);
749 749
750 // Check that the navigation is still suspended because the old RVH 750 // Check that the navigation is still suspended because the old RVH
751 // is not swapped out, yet. 751 // is not swapped out, yet.
752 EXPECT_TRUE(host2->render_view_host()->are_navigations_suspended()); 752 EXPECT_TRUE(host2->render_view_host()->are_navigations_suspended());
753 MockRenderProcessHost* test_process_host2 = 753 MockRenderProcessHost* test_process_host2 =
754 static_cast<MockRenderProcessHost*>(host2->GetProcess()); 754 static_cast<MockRenderProcessHost*>(host2->GetProcess());
755 test_process_host2->sink().ClearMessages(); 755 test_process_host2->sink().ClearMessages();
756 host2->render_view_host()->NavigateToURL(kUrl2); 756 host2->render_view_host()->NavigateToURL(kUrl2);
757 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( 757 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching(
758 ViewMsg_Navigate::ID)); 758 FrameMsg_Navigate::ID));
759 759
760 // Allow closing the current Render View (precondition for swapping out 760 // Allow closing the current Render View (precondition for swapping out
761 // the RVH): Simulate response from RenderView for ViewMsg_ShouldClose sent by 761 // the RVH): Simulate response from RenderView for ViewMsg_ShouldClose sent by
762 // FirePageBeforeUnload. 762 // FirePageBeforeUnload.
763 TestRenderViewHost* test_host = 763 TestRenderViewHost* test_host =
764 static_cast<TestRenderViewHost*>(host->render_view_host()); 764 static_cast<TestRenderViewHost*>(host->render_view_host());
765 MockRenderProcessHost* test_process_host = 765 MockRenderProcessHost* test_process_host =
766 static_cast<MockRenderProcessHost*>(test_host->GetProcess()); 766 static_cast<MockRenderProcessHost*>(test_host->GetProcess());
767 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 767 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
768 ViewMsg_ShouldClose::ID)); 768 ViewMsg_ShouldClose::ID));
769 test_host->SendShouldCloseACK(true); 769 test_host->SendShouldCloseACK(true);
770 770
771 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a 771 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a
772 // call of RenderFrameHostManager::SwapOutOldPage before 772 // call of RenderFrameHostManager::SwapOutOldPage before
773 // RenderFrameHostManager::DidNavigateMainFrame is called. 773 // RenderFrameHostManager::DidNavigateMainFrame is called.
774 // The RVH is swapped out after receiving the unload ack. 774 // The RVH is swapped out after receiving the unload ack.
775 manager->SwapOutOldPage(); 775 manager->SwapOutOldPage();
776 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( 776 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching(
777 ViewMsg_SwapOut::ID)); 777 ViewMsg_SwapOut::ID));
778 test_host->OnSwappedOut(false); 778 test_host->OnSwappedOut(false);
779 779
780 EXPECT_EQ(host, manager->current_frame_host()); 780 EXPECT_EQ(host, manager->current_frame_host());
781 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out()); 781 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out());
782 EXPECT_EQ(host2, manager->pending_frame_host()); 782 EXPECT_EQ(host2, manager->pending_frame_host());
783 // There should be still no navigation messages being sent. 783 // There should be still no navigation messages being sent.
784 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( 784 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching(
785 ViewMsg_Navigate::ID)); 785 FrameMsg_Navigate::ID));
786 786
787 // 3) Cross-site navigate to next site before 2) has committed. -------------- 787 // 3) Cross-site navigate to next site before 2) has committed. --------------
788 const GURL kUrl3("http://webkit.org/"); 788 const GURL kUrl3("http://webkit.org/");
789 NavigationEntryImpl entry3(NULL /* instance */, -1 /* page_id */, kUrl3, 789 NavigationEntryImpl entry3(NULL /* instance */, -1 /* page_id */, kUrl3,
790 Referrer(), base::string16() /* title */, 790 Referrer(), base::string16() /* title */,
791 PAGE_TRANSITION_TYPED, 791 PAGE_TRANSITION_TYPED,
792 false /* is_renderer_init */); 792 false /* is_renderer_init */);
793 test_process_host->sink().ClearMessages(); 793 test_process_host->sink().ClearMessages();
794 RenderFrameHostImpl* host3 = manager->Navigate(entry3); 794 RenderFrameHostImpl* host3 = manager->Navigate(entry3);
795 795
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 1564
1565 // Simulate the swap out ack. 1565 // Simulate the swap out ack.
1566 rvh1->OnSwappedOut(false); 1566 rvh1->OnSwappedOut(false);
1567 1567
1568 // rvh1 should be swapped out. 1568 // rvh1 should be swapped out.
1569 EXPECT_FALSE(destruction_observer.rvh_deleted()); 1569 EXPECT_FALSE(destruction_observer.rvh_deleted());
1570 EXPECT_TRUE(rvh1->IsSwappedOut()); 1570 EXPECT_TRUE(rvh1->IsSwappedOut());
1571 } 1571 }
1572 1572
1573 } // namespace content 1573 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/renderer_host/render_view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698