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_
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
;
21 class TestRenderFrameHostCreationObserver
: public WebContentsObserver
{
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_
; }
32 RenderFrameHost
* last_created_frame_
;
35 class TestRenderFrameHost
: public RenderFrameHostImpl
,
36 public RenderFrameHostTester
{
38 TestRenderFrameHost(RenderViewHostImpl
* render_view_host
,
39 RenderFrameHostDelegate
* delegate
,
40 FrameTree
* frame_tree
,
41 FrameTreeNode
* frame_tree_node
,
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
,
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(
60 const GURL
& url
, PageTransition transition
,
62 void SendNavigateWithOriginalRequestURL(
65 const GURL
& original_request_url
);
66 void SendNavigateWithFile(
69 const base::FilePath
& file_path
);
70 void SendNavigateWithParams(
71 FrameHostMsg_DidCommitProvisionalLoad_Params
* params
);
72 void SendNavigateWithRedirects(
75 const std::vector
<GURL
>& redirects
);
76 void SendNavigateWithParameters(
79 PageTransition transition
,
80 const GURL
& original_request_url
,
82 const base::FilePath
* file_path_for_history_item
,
83 const std::vector
<GURL
>& redirects
);
84 void SendBeginNavigationWithURL(const GURL
& url
);
86 void set_contents_mime_type(const std::string
& mime_type
) {
87 contents_mime_type_
= mime_type
;
90 // If set, navigations will appear to have cleared the history list in the
92 // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared).
94 void set_simulate_history_list_was_cleared(bool cleared
) {
95 simulate_history_list_was_cleared_
= cleared
;
98 // TODO(nick): As necessary for testing, override behavior of RenderFrameHost
102 TestRenderFrameHostCreationObserver child_creation_observer_
;
104 std::string contents_mime_type_
;
106 // See set_simulate_history_list_was_cleared() above.
107 bool simulate_history_list_was_cleared_
;
109 DISALLOW_COPY_AND_ASSIGN(TestRenderFrameHost
);
112 } // namespace content
114 #endif // CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_