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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_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 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/browser/frame_host/cross_site_transferring_request.h" 10 #include "content/browser/frame_host/cross_site_transferring_request.h"
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 FrameHostMsg_PluginCrashed( 556 FrameHostMsg_PluginCrashed(
557 ntp_rfh->GetRoutingID(), base::FilePath(), 0))); 557 ntp_rfh->GetRoutingID(), base::FilePath(), 0)));
558 EXPECT_FALSE(observer.plugin_crashed()); 558 EXPECT_FALSE(observer.plugin_crashed());
559 } 559 }
560 #endif 560 #endif
561 561
562 // We cannot filter out synchronous IPC messages, because the renderer would 562 // We cannot filter out synchronous IPC messages, because the renderer would
563 // be left waiting for a reply. We pick RunBeforeUnloadConfirm as an example 563 // be left waiting for a reply. We pick RunBeforeUnloadConfirm as an example
564 // that can run easily within a unit test, and that needs to receive a reply 564 // that can run easily within a unit test, and that needs to receive a reply
565 // without showing an actual dialog. 565 // without showing an actual dialog.
566 MockRenderProcessHost* ntp_process_host = 566 MockRenderProcessHost* ntp_process_host = ntp_rfh->GetProcess();
567 static_cast<MockRenderProcessHost*>(ntp_rfh->GetProcess());
568 ntp_process_host->sink().ClearMessages(); 567 ntp_process_host->sink().ClearMessages();
569 const base::string16 msg = base::ASCIIToUTF16("Message"); 568 const base::string16 msg = base::ASCIIToUTF16("Message");
570 bool result = false; 569 bool result = false;
571 base::string16 unused; 570 base::string16 unused;
572 FrameHostMsg_RunBeforeUnloadConfirm before_unload_msg( 571 FrameHostMsg_RunBeforeUnloadConfirm before_unload_msg(
573 ntp_rfh->GetRoutingID(), kChromeURL, msg, false, &result, &unused); 572 ntp_rfh->GetRoutingID(), kChromeURL, msg, false, &result, &unused);
574 // Enable pumping for check in BrowserMessageFilter::CheckCanDispatchOnUI. 573 // Enable pumping for check in BrowserMessageFilter::CheckCanDispatchOnUI.
575 before_unload_msg.EnableMessagePumping(); 574 before_unload_msg.EnableMessagePumping();
576 EXPECT_TRUE(ntp_rfh->OnMessageReceived(before_unload_msg)); 575 EXPECT_TRUE(ntp_rfh->OnMessageReceived(before_unload_msg));
577 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); 576 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 } 628 }
630 } 629 }
631 630
632 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) { 631 TEST_F(RenderFrameHostManagerTest, WhiteListSwapCompositorFrame) {
633 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost(); 632 TestRenderFrameHost* swapped_out_rfh = CreateSwappedOutRenderFrameHost();
634 TestRenderWidgetHostView* swapped_out_rwhv = 633 TestRenderWidgetHostView* swapped_out_rwhv =
635 static_cast<TestRenderWidgetHostView*>( 634 static_cast<TestRenderWidgetHostView*>(
636 swapped_out_rfh->GetRenderViewHost()->GetView()); 635 swapped_out_rfh->GetRenderViewHost()->GetView());
637 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame()); 636 EXPECT_FALSE(swapped_out_rwhv->did_swap_compositor_frame());
638 637
639 MockRenderProcessHost* process_host = 638 MockRenderProcessHost* process_host = swapped_out_rfh->GetProcess();
640 static_cast<MockRenderProcessHost*>(swapped_out_rfh->GetProcess());
641 process_host->sink().ClearMessages(); 639 process_host->sink().ClearMessages();
642 640
643 cc::CompositorFrame frame; 641 cc::CompositorFrame frame;
644 ViewHostMsg_SwapCompositorFrame msg( 642 ViewHostMsg_SwapCompositorFrame msg(
645 rvh()->GetRoutingID(), 0, frame, std::vector<IPC::Message>()); 643 rvh()->GetRoutingID(), 0, frame, std::vector<IPC::Message>());
646 644
647 EXPECT_TRUE(swapped_out_rfh->render_view_host()->OnMessageReceived(msg)); 645 EXPECT_TRUE(swapped_out_rfh->render_view_host()->OnMessageReceived(msg));
648 EXPECT_TRUE(swapped_out_rwhv->did_swap_compositor_frame()); 646 EXPECT_TRUE(swapped_out_rwhv->did_swap_compositor_frame());
649 } 647 }
650 648
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); 2051 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive());
2054 contents2->NavigateAndCommit(kUrl3); 2052 contents2->NavigateAndCommit(kUrl3);
2055 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); 2053 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive());
2056 EXPECT_NE(nullptr, 2054 EXPECT_NE(nullptr,
2057 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); 2055 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance()));
2058 EXPECT_EQ(nullptr, 2056 EXPECT_EQ(nullptr,
2059 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); 2057 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance()));
2060 } 2058 }
2061 2059
2062 } // namespace content 2060 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl_unittest.cc ('k') | content/test/test_render_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698