GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / content / test / test_render_frame_host.h
blobebc79575e1d1e13f2ea22447b9f9ad68b658c889
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(SiteInstance* site_instance,
39 RenderViewHostImpl* render_view_host,
40 RenderFrameHostDelegate* delegate,
41 RenderWidgetHostDelegate* rwh_delegate,
42 FrameTree* frame_tree,
43 FrameTreeNode* frame_tree_node,
44 int routing_id,
45 int flags);
46 ~TestRenderFrameHost() override;
48 // RenderFrameHostImpl overrides (same values, but in Test* types)
49 TestRenderViewHost* GetRenderViewHost() override;
51 // RenderFrameHostTester implementation.
52 TestRenderFrameHost* AppendChild(const std::string& frame_name) override;
53 void SendNavigate(int page_id, const GURL& url) override;
54 void SendFailedNavigate(int page_id, const GURL& url) override;
55 void SendNavigateWithTransition(int page_id,
56 const GURL& url,
57 ui::PageTransition transition) override;
58 void SetContentsMimeType(const std::string& mime_type) override;
59 void SendBeforeUnloadACK(bool proceed) override;
60 void SimulateSwapOutACK() override;
62 void SendNavigateWithTransitionAndResponseCode(
63 int page_id,
64 const GURL& url, ui::PageTransition transition,
65 int response_code);
66 void SendNavigateWithOriginalRequestURL(
67 int page_id,
68 const GURL& url,
69 const GURL& original_request_url);
70 void SendNavigateWithFile(
71 int page_id,
72 const GURL& url,
73 const base::FilePath& file_path);
74 void SendNavigateWithParams(
75 FrameHostMsg_DidCommitProvisionalLoad_Params* params);
76 void SendNavigateWithRedirects(
77 int page_id,
78 const GURL& url,
79 const std::vector<GURL>& redirects);
80 void SendNavigateWithParameters(
81 int page_id,
82 const GURL& url,
83 ui::PageTransition transition,
84 const GURL& original_request_url,
85 int response_code,
86 const base::FilePath* file_path_for_history_item,
87 const std::vector<GURL>& redirects);
89 // With the current navigation logic this method is a no-op.
90 // PlzNavigate: this method simulates receiving a BeginNavigation IPC.
91 void SendRendererInitiatedNavigationRequest(const GURL& url,
92 bool has_user_gesture);
94 void DidDisownOpener();
96 // If set, navigations will appear to have cleared the history list in the
97 // RenderFrame
98 // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared).
99 // False by default.
100 void set_simulate_history_list_was_cleared(bool cleared) {
101 simulate_history_list_was_cleared_ = cleared;
104 // Advances the RenderFrameHost (and through it the RenderFrameHostManager) to
105 // a state where a new navigation can be committed by a renderer. Currently,
106 // this simulates a BeforeUnload ACK from the renderer.
107 // PlzNavigate: this simulates a BeforeUnload ACK from the renderer, and the
108 // interaction with the IO thread up until the response is ready to commit.
109 void PrepareForCommit();
111 // This method does the same as PrepareForCommit.
112 // PlzNavigate: Beyond doing the same as PrepareForCommit, this method will
113 // also simulate a server redirect to |redirect_url|. If the URL is empty the
114 // redirect step is ignored.
115 void PrepareForCommitWithServerRedirect(const GURL& redirect_url);
117 private:
118 TestRenderFrameHostCreationObserver child_creation_observer_;
120 std::string contents_mime_type_;
122 // See set_simulate_history_list_was_cleared() above.
123 bool simulate_history_list_was_cleared_;
125 DISALLOW_COPY_AND_ASSIGN(TestRenderFrameHost);
128 } // namespace content
130 #endif // CONTENT_TEST_TEST_RENDER_FRAME_HOST_H_