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"
16 struct FrameHostMsg_DidCommitProvisionalLoad_Params
;
20 class TestRenderFrameHostCreationObserver
: public WebContentsObserver
{
22 explicit TestRenderFrameHostCreationObserver(WebContents
* web_contents
);
23 virtual ~TestRenderFrameHostCreationObserver();
25 // WebContentsObserver implementation.
26 virtual void RenderFrameCreated(RenderFrameHost
* render_frame_host
) OVERRIDE
;
28 RenderFrameHost
* last_created_frame() const { return last_created_frame_
; }
31 RenderFrameHost
* last_created_frame_
;
34 class TestRenderFrameHost
: public RenderFrameHostImpl
,
35 public RenderFrameHostTester
{
37 TestRenderFrameHost(RenderViewHostImpl
* render_view_host
,
38 RenderFrameHostDelegate
* delegate
,
39 FrameTree
* frame_tree
,
40 FrameTreeNode
* frame_tree_node
,
43 virtual ~TestRenderFrameHost();
45 // RenderFrameHostTester implementation.
46 virtual RenderFrameHost
* AppendChild(const std::string
& frame_name
) OVERRIDE
;
47 virtual void SendNavigateWithTransition(int page_id
,
49 PageTransition transition
) OVERRIDE
;
51 void SendNavigate(int page_id
, const GURL
& url
);
52 void SendFailedNavigate(int page_id
, const GURL
& url
);
53 void SendNavigateWithTransitionAndResponseCode(
55 const GURL
& url
, PageTransition transition
,
57 void SendNavigateWithOriginalRequestURL(
60 const GURL
& original_request_url
);
61 void SendNavigateWithFile(
64 const base::FilePath
& file_path
);
65 void SendNavigateWithParams(
66 FrameHostMsg_DidCommitProvisionalLoad_Params
* params
);
67 void SendNavigateWithRedirects(
70 const std::vector
<GURL
>& redirects
);
71 void SendNavigateWithParameters(
74 PageTransition transition
,
75 const GURL
& original_request_url
,
77 const base::FilePath
* file_path_for_history_item
,
78 const std::vector
<GURL
>& redirects
);
79 void SendBeginNavigationWithURL(const GURL
& url
);
81 void set_contents_mime_type(const std::string
& mime_type
) {
82 contents_mime_type_
= mime_type
;
85 // If set, navigations will appear to have cleared the history list in the
87 // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared).
89 void set_simulate_history_list_was_cleared(bool cleared
) {
90 simulate_history_list_was_cleared_
= cleared
;
93 // TODO(nick): As necessary for testing, override behavior of RenderFrameHost
97 TestRenderFrameHostCreationObserver child_creation_observer_
;
99 std::string contents_mime_type_
;
101 // See set_simulate_history_list_was_cleared() above.
102 bool simulate_history_list_was_cleared_
;
104 DISALLOW_COPY_AND_ASSIGN(TestRenderFrameHost
);
107 } // namespace content
109 #endif // CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_