Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / content / test / test_render_frame_host.h
blob621bc6debebb57c896f0d0209dc394bf7701c5ac
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/test_renderer_host.h"
14 #include "content/test/test_render_view_host.h"
15 #include "ui/base/page_transition_types.h"
17 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
19 namespace content {
21 class TestRenderFrameHostCreationObserver : public WebContentsObserver {
22 public:
23 explicit TestRenderFrameHostCreationObserver(WebContents* web_contents);
24 ~TestRenderFrameHostCreationObserver() override;
26 // WebContentsObserver implementation.
27 void RenderFrameCreated(RenderFrameHost* render_frame_host) override;
29 RenderFrameHost* last_created_frame() const { return last_created_frame_; }
31 private:
32 RenderFrameHost* last_created_frame_;
35 class TestRenderFrameHost : public RenderFrameHostImpl,
36 public RenderFrameHostTester {
37 public:
38 TestRenderFrameHost(RenderViewHostImpl* render_view_host,
39 RenderFrameHostDelegate* delegate,
40 FrameTree* frame_tree,
41 FrameTreeNode* frame_tree_node,
42 int routing_id,
43 int flags);
44 ~TestRenderFrameHost() override;
46 // RenderFrameHostImpl overrides (same values, but in Test* types)
47 TestRenderViewHost* GetRenderViewHost() override;
49 // RenderFrameHostTester implementation.
50 TestRenderFrameHost* AppendChild(const std::string& frame_name) override;
51 void SendNavigate(int page_id, const GURL& url) override;
52 void SendFailedNavigate(int page_id, const GURL& url) override;
53 void SendNavigateWithTransition(int page_id,
54 const GURL& url,
55 ui::PageTransition transition) override;
56 void SetContentsMimeType(const std::string& mime_type) override;
57 void SendBeforeUnloadACK(bool proceed) override;
58 void SimulateSwapOutACK() override;
60 void SendNavigateWithTransitionAndResponseCode(
61 int page_id,
62 const GURL& url, ui::PageTransition transition,
63 int response_code);
64 void SendNavigateWithOriginalRequestURL(
65 int page_id,
66 const GURL& url,
67 const GURL& original_request_url);
68 void SendNavigateWithFile(
69 int page_id,
70 const GURL& url,
71 const base::FilePath& file_path);
72 void SendNavigateWithParams(
73 FrameHostMsg_DidCommitProvisionalLoad_Params* params);
74 void SendNavigateWithRedirects(
75 int page_id,
76 const GURL& url,
77 const std::vector<GURL>& redirects);
78 void SendNavigateWithParameters(
79 int page_id,
80 const GURL& url,
81 ui::PageTransition transition,
82 const GURL& original_request_url,
83 int response_code,
84 const base::FilePath* file_path_for_history_item,
85 const std::vector<GURL>& redirects);
86 void SendBeginNavigationWithURL(const GURL& url);
88 void DidDisownOpener();
90 // If set, navigations will appear to have cleared the history list in the
91 // RenderFrame
92 // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared).
93 // False by default.
94 void set_simulate_history_list_was_cleared(bool cleared) {
95 simulate_history_list_was_cleared_ = cleared;
98 // Advances the RenderFrameHost (and through it the RenderFrameHostManager) to
99 // a state where a new navigation can be committed by a renderer. Currently,
100 // this simulates a BeforeUnload ACK from the renderer.
101 // PlzNavigate: this simulates a BeforeUnload ACK from the renderer, and the
102 // interaction with the IO thread up until the response is ready to commit.
103 void PrepareForCommit(const GURL& url);
105 private:
106 TestRenderFrameHostCreationObserver child_creation_observer_;
108 std::string contents_mime_type_;
110 // See set_simulate_history_list_was_cleared() above.
111 bool simulate_history_list_was_cleared_;
113 DISALLOW_COPY_AND_ASSIGN(TestRenderFrameHost);
116 } // namespace content
118 #endif // CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_