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

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

Issue 1051343005: Add covariant overrides to TestRVH::GetProcess and TestRFH::GetProcess (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@unittest_frame_liveness
Patch Set: Rebase Created 5 years, 8 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 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/browser/frame_host/navigation_controller_impl.h" 8 #include "content/browser/frame_host/navigation_controller_impl.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/frame_host/navigation_request.h" 10 #include "content/browser/frame_host/navigation_request.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 TestRenderFrameHost* GetSpeculativeRenderFrameHost(FrameTreeNode* node) { 77 TestRenderFrameHost* GetSpeculativeRenderFrameHost(FrameTreeNode* node) {
78 return static_cast<TestRenderFrameHost*>( 78 return static_cast<TestRenderFrameHost*>(
79 node->render_manager()->speculative_render_frame_host_.get()); 79 node->render_manager()->speculative_render_frame_host_.get());
80 } 80 }
81 81
82 // Checks if this RenderFrameHost sent a single FrameMsg_CommitNavigation 82 // Checks if this RenderFrameHost sent a single FrameMsg_CommitNavigation
83 // since the last clearing of the sink. 83 // since the last clearing of the sink.
84 // Note: caller must invoke ClearMessages on the sink at some point before 84 // Note: caller must invoke ClearMessages on the sink at some point before
85 // the tracked commit happens to clear up commit messages from previous 85 // the tracked commit happens to clear up commit messages from previous
86 // navigations. 86 // navigations.
87 bool DidRenderFrameHostRequestCommit(RenderFrameHostImpl* rfh) { 87 bool DidRenderFrameHostRequestCommit(TestRenderFrameHost* rfh) {
88 MockRenderProcessHost* rph =
89 static_cast<MockRenderProcessHost*>(rfh->GetProcess());
90 const FrameMsg_CommitNavigation* commit_message = 88 const FrameMsg_CommitNavigation* commit_message =
91 static_cast<const FrameMsg_CommitNavigation*>( 89 static_cast<const FrameMsg_CommitNavigation*>(
92 rph->sink().GetUniqueMessageMatching( 90 rfh->GetProcess()->sink().GetUniqueMessageMatching(
93 FrameMsg_CommitNavigation::ID)); 91 FrameMsg_CommitNavigation::ID));
94 return commit_message && 92 return commit_message &&
95 rfh->GetRoutingID() == commit_message->routing_id(); 93 rfh->GetRoutingID() == commit_message->routing_id();
96 } 94 }
97 95
98 SiteInstance* ConvertToSiteInstance(RenderFrameHostManager* rfhm, 96 SiteInstance* ConvertToSiteInstance(RenderFrameHostManager* rfhm,
99 const SiteInstanceDescriptor& descriptor, 97 const SiteInstanceDescriptor& descriptor,
100 SiteInstance* candidate_instance) { 98 SiteInstance* candidate_instance) {
101 return rfhm->ConvertToSiteInstance(descriptor, candidate_instance); 99 return rfhm->ConvertToSiteInstance(descriptor, candidate_instance);
102 } 100 }
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 const GURL kUrl2("http://chromium.org/"); 929 const GURL kUrl2("http://chromium.org/");
932 contents()->NavigateAndCommit(kUrl2); 930 contents()->NavigateAndCommit(kUrl2);
933 ASSERT_NE(rfh1, main_test_rfh()); 931 ASSERT_NE(rfh1, main_test_rfh());
934 EXPECT_NE(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); 932 EXPECT_NE(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state());
935 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); 933 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state());
936 EXPECT_TRUE(rfhm->IsOnSwappedOutList(rfh1)); 934 EXPECT_TRUE(rfhm->IsOnSwappedOutList(rfh1));
937 935
938 // Now go back to the initial site so that the swapped out RenderFrameHost 936 // Now go back to the initial site so that the swapped out RenderFrameHost
939 // should be reused. 937 // should be reused.
940 process()->sink().ClearMessages(); 938 process()->sink().ClearMessages();
941 static_cast<MockRenderProcessHost*>(rfh1->GetProcess()) 939 rfh1->GetProcess()->sink().ClearMessages();
942 ->sink()
943 .ClearMessages();
944 RequestNavigation(node, kUrl1); 940 RequestNavigation(node, kUrl1);
945 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); 941 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
946 942
947 main_test_rfh()->SendBeforeUnloadACK(true); 943 main_test_rfh()->SendBeforeUnloadACK(true);
948 EXPECT_EQ(rfh1, GetSpeculativeRenderFrameHost(node)); 944 EXPECT_EQ(rfh1, GetSpeculativeRenderFrameHost(node));
949 EXPECT_NE(RenderFrameHostImpl::STATE_DEFAULT, 945 EXPECT_NE(RenderFrameHostImpl::STATE_DEFAULT,
950 GetSpeculativeRenderFrameHost(node)->rfh_state()); 946 GetSpeculativeRenderFrameHost(node)->rfh_state());
951 947
952 scoped_refptr<ResourceResponse> response(new ResourceResponse); 948 scoped_refptr<ResourceResponse> response(new ResourceResponse);
953 GetLoaderForNavigationRequest(GetNavigationRequestForFrameTreeNode(node)) 949 GetLoaderForNavigationRequest(GetNavigationRequestForFrameTreeNode(node))
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 1126
1131 SiteInstance* converted_instance_2 = 1127 SiteInstance* converted_instance_2 =
1132 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get()); 1128 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get());
1133 // Should return |unrelated_instance| because its site matches and it is 1129 // Should return |unrelated_instance| because its site matches and it is
1134 // unrelated to the current SiteInstance. 1130 // unrelated to the current SiteInstance.
1135 EXPECT_EQ(unrelated_instance.get(), converted_instance_2); 1131 EXPECT_EQ(unrelated_instance.get(), converted_instance_2);
1136 } 1132 }
1137 } 1133 }
1138 1134
1139 } // namespace content 1135 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698