Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / test / test_render_frame_host.h
blobec6be4dc7fa4e9bf2266467497a2e4ee3b3fa712
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/common/page_transition_types.h"
14 #include "content/public/test/test_renderer_host.h"
15 #include "content/test/test_render_view_host.h"
17 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
19 namespace content {
21 class TestRenderFrameHostCreationObserver : public WebContentsObserver {
22 public:
23 explicit TestRenderFrameHostCreationObserver(WebContents* web_contents);
24 virtual ~TestRenderFrameHostCreationObserver();
26 // WebContentsObserver implementation.
27 virtual 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 bool is_swapped_out);
44 virtual ~TestRenderFrameHost();
46 // RenderFrameHostImpl overrides (same values, but in Test* types)
47 virtual TestRenderViewHost* GetRenderViewHost() OVERRIDE;
49 // RenderFrameHostTester implementation.
50 virtual TestRenderFrameHost* AppendChild(
51 const std::string& frame_name) OVERRIDE;
52 virtual void SendNavigateWithTransition(int page_id,
53 const GURL& url,
54 PageTransition transition) OVERRIDE;
56 void SendNavigate(int page_id, const GURL& url);
57 void SendFailedNavigate(int page_id, const GURL& url);
58 void SendNavigateWithTransitionAndResponseCode(
59 int page_id,
60 const GURL& url, PageTransition transition,
61 int response_code);
62 void SendNavigateWithOriginalRequestURL(
63 int page_id,
64 const GURL& url,
65 const GURL& original_request_url);
66 void SendNavigateWithFile(
67 int page_id,
68 const GURL& url,
69 const base::FilePath& file_path);
70 void SendNavigateWithParams(
71 FrameHostMsg_DidCommitProvisionalLoad_Params* params);
72 void SendNavigateWithRedirects(
73 int page_id,
74 const GURL& url,
75 const std::vector<GURL>& redirects);
76 void SendNavigateWithParameters(
77 int page_id,
78 const GURL& url,
79 PageTransition transition,
80 const GURL& original_request_url,
81 int response_code,
82 const base::FilePath* file_path_for_history_item,
83 const std::vector<GURL>& redirects);
84 void SendBeginNavigationWithURL(const GURL& url);
86 void DidDisownOpener();
88 void set_contents_mime_type(const std::string& mime_type) {
89 contents_mime_type_ = mime_type;
92 // If set, navigations will appear to have cleared the history list in the
93 // RenderFrame
94 // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared).
95 // False by default.
96 void set_simulate_history_list_was_cleared(bool cleared) {
97 simulate_history_list_was_cleared_ = cleared;
100 // TODO(nick): As necessary for testing, override behavior of RenderFrameHost
101 // here.
103 private:
104 TestRenderFrameHostCreationObserver child_creation_observer_;
106 std::string contents_mime_type_;
108 // See set_simulate_history_list_was_cleared() above.
109 bool simulate_history_list_was_cleared_;
111 DISALLOW_COPY_AND_ASSIGN(TestRenderFrameHost);
114 } // namespace content
116 #endif // CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_