• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_
6 #define CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_
7 
8 #include <vector>
9 
10 #include "base/basictypes.h"
11 #include "content/browser/frame_host/render_frame_host_impl.h"
12 #include "content/public/common/page_transition_types.h"
13 
14 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
15 
16 namespace content {
17 
18 class TestRenderFrameHost : public RenderFrameHostImpl {
19  public:
20   TestRenderFrameHost(RenderViewHostImpl* render_view_host,
21                       RenderFrameHostDelegate* delegate,
22                       FrameTree* frame_tree,
23                       FrameTreeNode* frame_tree_node,
24                       int routing_id,
25                       bool is_swapped_out);
26   virtual ~TestRenderFrameHost();
27 
28   void SendNavigate(int page_id, const GURL& url);
29   void SendNavigateWithTransition(
30       int page_id,
31       const GURL& url,
32       PageTransition transition);
33   void SendFailedNavigate(int page_id, const GURL& url);
34   void SendNavigateWithTransitionAndResponseCode(
35       int page_id,
36       const GURL& url, PageTransition transition,
37       int response_code);
38   void SendNavigateWithOriginalRequestURL(
39       int page_id,
40       const GURL& url,
41       const GURL& original_request_url);
42   void SendNavigateWithFile(
43       int page_id,
44       const GURL& url,
45       const base::FilePath& file_path);
46   void SendNavigateWithParams(
47       FrameHostMsg_DidCommitProvisionalLoad_Params* params);
48   void SendNavigateWithRedirects(
49       int page_id,
50       const GURL& url,
51       const std::vector<GURL>& redirects);
52   void SendNavigateWithParameters(
53       int page_id,
54       const GURL& url,
55       PageTransition transition,
56       const GURL& original_request_url,
57       int response_code,
58       const base::FilePath* file_path_for_history_item,
59       const std::vector<GURL>& redirects);
60 
set_contents_mime_type(const std::string & mime_type)61   void set_contents_mime_type(const std::string& mime_type) {
62     contents_mime_type_ = mime_type;
63   }
64 
65   // If set, navigations will appear to have cleared the history list in the
66   // RenderFrame
67   // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared).
68   // False by default.
set_simulate_history_list_was_cleared(bool cleared)69   void set_simulate_history_list_was_cleared(bool cleared) {
70     simulate_history_list_was_cleared_ = cleared;
71   }
72 
73   // TODO(nick): As necessary for testing, override behavior of RenderFrameHost
74   // here.
75 
76  private:
77   std::string contents_mime_type_;
78 
79   // See set_simulate_history_list_was_cleared() above.
80   bool simulate_history_list_was_cleared_;
81 
82   DISALLOW_COPY_AND_ASSIGN(TestRenderFrameHost);
83 };
84 
85 }  // namespace content
86 
87 #endif  // CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_
88