cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / content / test / test_render_frame_host.h
blobf17811771863922652264887de871f5011cf74a7
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_
6 #define CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "content/browser/frame_host/render_frame_host_impl.h"
12 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/test/mock_render_process_host.h"
14 #include "content/public/test/test_renderer_host.h"
15 #include "content/test/test_render_view_host.h"
16 #include "ui/base/page_transition_types.h"
18 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
20 namespace content {
22 class TestRenderFrameHostCreationObserver : public WebContentsObserver {
23 public:
24 explicit TestRenderFrameHostCreationObserver(WebContents* web_contents);
25 ~TestRenderFrameHostCreationObserver() override;
27 // WebContentsObserver implementation.
28 void RenderFrameCreated(RenderFrameHost* render_frame_host) override;
30 RenderFrameHost* last_created_frame() const { return last_created_frame_; }
32 private:
33 RenderFrameHost* last_created_frame_;
36 class TestRenderFrameHost : public RenderFrameHostImpl,
37 public RenderFrameHostTester {
38 public:
39 TestRenderFrameHost(SiteInstance* site_instance,
40 RenderViewHostImpl* render_view_host,
41 RenderFrameHostDelegate* delegate,
42 RenderWidgetHostDelegate* rwh_delegate,
43 FrameTree* frame_tree,
44 FrameTreeNode* frame_tree_node,
45 int32 routing_id,
46 int32 widget_routing_id,
47 int32 surface_id,
48 int flags);
49 ~TestRenderFrameHost() override;
51 // RenderFrameHostImpl overrides (same values, but in Test*/Mock* types)
52 TestRenderViewHost* GetRenderViewHost() override;
53 MockRenderProcessHost* GetProcess() override;
55 // RenderFrameHostTester implementation.
56 void InitializeRenderFrameIfNeeded() override;
57 TestRenderFrameHost* AppendChild(const std::string& frame_name) override;
58 void SimulateNavigationStart(const GURL& url) override;
59 void SimulateRedirect(const GURL& new_url) override;
60 void SimulateNavigationCommit(const GURL& url) override;
61 void SimulateNavigationError(const GURL& url, int error_code) override;
62 void SimulateNavigationErrorPageCommit() override;
63 void SimulateNavigationStop() override;
64 void SendNavigate(int page_id,
65 int nav_entry_id,
66 bool did_create_new_entry,
67 const GURL& url) override;
68 void SendFailedNavigate(int page_id,
69 int nav_entry_id,
70 bool did_create_new_entry,
71 const GURL& url) override;
72 void SendNavigateWithTransition(int page_id,
73 int nav_entry_id,
74 bool did_create_new_entry,
75 const GURL& url,
76 ui::PageTransition transition) override;
77 void SetContentsMimeType(const std::string& mime_type) override;
78 void SendBeforeUnloadACK(bool proceed) override;
79 void SimulateSwapOutACK() override;
81 using ModificationCallback =
82 base::Callback<void(FrameHostMsg_DidCommitProvisionalLoad_Params*)>;
84 void SendNavigateWithModificationCallback(
85 int page_id,
86 int nav_entry_id,
87 bool did_create_new_entry,
88 const GURL& url,
89 const ModificationCallback& callback);
90 void SendNavigateWithParams(
91 FrameHostMsg_DidCommitProvisionalLoad_Params* params);
93 // Simulate a renderer-initiated navigation up until commit.
94 void NavigateAndCommitRendererInitiated(int page_id,
95 bool did_create_new_entry,
96 const GURL& url);
98 // With the current navigation logic this method is a no-op.
99 // PlzNavigate: this method simulates receiving a BeginNavigation IPC.
100 void SendRendererInitiatedNavigationRequest(const GURL& url,
101 bool has_user_gesture);
103 void DidChangeOpener(int opener_routing_id);
105 // If set, navigations will appear to have cleared the history list in the
106 // RenderFrame
107 // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared).
108 // False by default.
109 void set_simulate_history_list_was_cleared(bool cleared) {
110 simulate_history_list_was_cleared_ = cleared;
113 // Advances the RenderFrameHost (and through it the RenderFrameHostManager) to
114 // a state where a new navigation can be committed by a renderer. Currently,
115 // this simulates a BeforeUnload ACK from the renderer.
116 // PlzNavigate: this simulates a BeforeUnload ACK from the renderer, and the
117 // interaction with the IO thread up until the response is ready to commit.
118 void PrepareForCommit();
120 // This method does the same as PrepareForCommit.
121 // PlzNavigate: Beyond doing the same as PrepareForCommit, this method will
122 // also simulate a server redirect to |redirect_url|. If the URL is empty the
123 // redirect step is ignored.
124 void PrepareForCommitWithServerRedirect(const GURL& redirect_url);
126 // PlzNavigate
127 void set_pending_commit(bool pending) { pending_commit_ = pending; }
128 bool pending_commit() const { return pending_commit_; }
130 private:
131 void SendNavigateWithParameters(int page_id,
132 int nav_entry_id,
133 bool did_create_new_entry,
134 const GURL& url,
135 ui::PageTransition transition,
136 int response_code,
137 const ModificationCallback& callback);
139 // Computes the page ID for a pending navigation in this RenderFrameHost;
140 int32 ComputeNextPageID();
142 TestRenderFrameHostCreationObserver child_creation_observer_;
144 std::string contents_mime_type_;
146 // See set_simulate_history_list_was_cleared() above.
147 bool simulate_history_list_was_cleared_;
149 DISALLOW_COPY_AND_ASSIGN(TestRenderFrameHost);
152 } // namespace content
154 #endif // CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_