Update broken references to image assets
[chromium-blink-merge.git] / content / test / test_render_frame_host.h
blob2cd0b992012f16d398ab5ebd6c08b57b2c03e8b9
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 int routing_id,
46 int flags);
47 ~TestRenderFrameHost() override;
49 // RenderFrameHostImpl overrides (same values, but in Test*/Mock* types)
50 TestRenderViewHost* GetRenderViewHost() override;
51 MockRenderProcessHost* GetProcess() override;
53 // RenderFrameHostTester implementation.
54 void InitializeRenderFrameIfNeeded() override;
55 TestRenderFrameHost* AppendChild(const std::string& frame_name) override;
56 void SimulateNavigationStart(const GURL& url) override;
57 void SimulateRedirect(const GURL& new_url) override;
58 void SimulateNavigationCommit(const GURL& url) override;
59 void SimulateNavigationError(const GURL& url, int error_code) override;
60 void SimulateNavigationErrorPageCommit() override;
61 void SimulateNavigationStop() override;
62 void SendNavigate(int page_id,
63 int nav_entry_id,
64 bool did_create_new_entry,
65 const GURL& url) override;
66 void SendFailedNavigate(int page_id,
67 int nav_entry_id,
68 bool did_create_new_entry,
69 const GURL& url) override;
70 void SendNavigateWithTransition(int page_id,
71 int nav_entry_id,
72 bool did_create_new_entry,
73 const GURL& url,
74 ui::PageTransition transition) override;
75 void SetContentsMimeType(const std::string& mime_type) override;
76 void SendBeforeUnloadACK(bool proceed) override;
77 void SimulateSwapOutACK() override;
79 using ModificationCallback =
80 base::Callback<void(FrameHostMsg_DidCommitProvisionalLoad_Params*)>;
82 void SendNavigateWithModificationCallback(
83 int page_id,
84 int nav_entry_id,
85 bool did_create_new_entry,
86 const GURL& url,
87 const ModificationCallback& callback);
88 void SendNavigateWithParams(
89 FrameHostMsg_DidCommitProvisionalLoad_Params* params);
91 // Simulate a renderer-initiated navigation up until commit.
92 void NavigateAndCommitRendererInitiated(int page_id,
93 bool did_create_new_entry,
94 const GURL& url);
96 // With the current navigation logic this method is a no-op.
97 // PlzNavigate: this method simulates receiving a BeginNavigation IPC.
98 void SendRendererInitiatedNavigationRequest(const GURL& url,
99 bool has_user_gesture);
101 void DidDisownOpener();
103 // If set, navigations will appear to have cleared the history list in the
104 // RenderFrame
105 // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared).
106 // False by default.
107 void set_simulate_history_list_was_cleared(bool cleared) {
108 simulate_history_list_was_cleared_ = cleared;
111 // Advances the RenderFrameHost (and through it the RenderFrameHostManager) to
112 // a state where a new navigation can be committed by a renderer. Currently,
113 // this simulates a BeforeUnload ACK from the renderer.
114 // PlzNavigate: this simulates a BeforeUnload ACK from the renderer, and the
115 // interaction with the IO thread up until the response is ready to commit.
116 void PrepareForCommit();
118 // This method does the same as PrepareForCommit.
119 // PlzNavigate: Beyond doing the same as PrepareForCommit, this method will
120 // also simulate a server redirect to |redirect_url|. If the URL is empty the
121 // redirect step is ignored.
122 void PrepareForCommitWithServerRedirect(const GURL& redirect_url);
124 // PlzNavigate
125 void set_pending_commit(bool pending) { pending_commit_ = pending; }
126 bool pending_commit() const { return pending_commit_; }
128 private:
129 void SendNavigateWithParameters(int page_id,
130 int nav_entry_id,
131 bool did_create_new_entry,
132 const GURL& url,
133 ui::PageTransition transition,
134 int response_code,
135 const ModificationCallback& callback);
137 // Computes the page ID for a pending navigation in this RenderFrameHost;
138 int32 ComputeNextPageID();
140 TestRenderFrameHostCreationObserver child_creation_observer_;
142 std::string contents_mime_type_;
144 // See set_simulate_history_list_was_cleared() above.
145 bool simulate_history_list_was_cleared_;
147 DISALLOW_COPY_AND_ASSIGN(TestRenderFrameHost);
150 } // namespace content
152 #endif // CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_