Update broken references to image assets
[chromium-blink-merge.git] / content / test / test_web_contents.h
blob17134f2bf0e76ee59f92c8afccbed84718157ad3
1 // Copyright (c) 2012 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_WEB_CONTENTS_H_
6 #define CONTENT_TEST_TEST_WEB_CONTENTS_H_
8 #include <string>
10 #include "content/browser/web_contents/web_contents_impl.h"
11 #include "content/public/test/web_contents_tester.h"
12 #include "content/test/test_render_frame_host.h"
13 #include "content/test/test_render_view_host.h"
14 #include "ui/base/page_transition_types.h"
16 class GURL;
17 class Referrer;
18 class SiteInstanceImpl;
20 namespace content {
22 class RenderViewHost;
23 class TestRenderViewHost;
24 class WebContentsTester;
26 // Subclass WebContentsImpl to ensure it creates TestRenderViewHosts
27 // and does not do anything involving views.
28 class TestWebContents : public WebContentsImpl, public WebContentsTester {
29 public:
30 ~TestWebContents() override;
32 static TestWebContents* Create(BrowserContext* browser_context,
33 SiteInstance* instance);
35 // WebContentsImpl overrides (returning the same values, but in Test* types)
36 TestRenderFrameHost* GetMainFrame() override;
37 TestRenderViewHost* GetRenderViewHost() const override;
38 // Overrides to avoid establishing Mojo connection with renderer process.
39 int DownloadImage(const GURL& url,
40 bool is_favicon,
41 uint32_t max_bitmap_size,
42 bool bypass_cache,
43 const ImageDownloadCallback& callback) override;
45 // WebContentsTester implementation.
46 void CommitPendingNavigation() override;
47 TestRenderFrameHost* GetPendingMainFrame() const override;
48 void StartNavigation(const GURL& url) override;
49 void NavigateAndCommit(const GURL& url) override;
50 void TestSetIsLoading(bool value) override;
51 void ProceedWithCrossSiteNavigation() override;
52 void TestDidNavigate(RenderFrameHost* render_frame_host,
53 int page_id,
54 int nav_entry_id,
55 bool did_create_new_entry,
56 const GURL& url,
57 ui::PageTransition transition) override;
58 void TestDidNavigateWithReferrer(RenderFrameHost* render_frame_host,
59 int page_id,
60 int nav_entry_id,
61 bool did_create_new_entry,
62 const GURL& url,
63 const Referrer& referrer,
64 ui::PageTransition transition) override;
65 const std::string& GetSaveFrameHeaders() override;
67 // True if a cross-site navigation is pending.
68 bool CrossProcessNavigationPending();
70 // Prevent interaction with views.
71 bool CreateRenderViewForRenderManager(
72 RenderViewHost* render_view_host,
73 int opener_frame_routing_id,
74 int proxy_routing_id,
75 const FrameReplicationState& replicated_frame_state,
76 bool for_main_frame) override;
77 void UpdateRenderViewSizeForRenderManager() override {}
79 // Returns a clone of this TestWebContents. The returned object is also a
80 // TestWebContents. The caller owns the returned object.
81 WebContents* Clone() override;
83 // Allow mocking of the RenderViewHostDelegateView.
84 RenderViewHostDelegateView* GetDelegateView() override;
85 void set_delegate_view(RenderViewHostDelegateView* view) {
86 delegate_view_override_ = view;
89 // Allows us to simulate this tab's main frame having an opener that points
90 // to the main frame of the |opener|.
91 void SetOpener(TestWebContents* opener);
93 // Allows us to simulate that a contents was created via CreateNewWindow.
94 void AddPendingContents(TestWebContents* contents);
96 // Establish expected arguments for |SetHistoryOffsetAndLength()|. When
97 // |SetHistoryOffsetAndLength()| is called, the arguments are compared
98 // with the expected arguments specified here.
99 void ExpectSetHistoryOffsetAndLength(int history_offset,
100 int history_length);
102 // Compares the arguments passed in with the expected arguments passed in
103 // to |ExpectSetHistoryOffsetAndLength()|.
104 void SetHistoryOffsetAndLength(int history_offset,
105 int history_length) override;
107 void TestDidFinishLoad(const GURL& url);
108 void TestDidFailLoadWithError(const GURL& url,
109 int error_code,
110 const base::string16& error_description,
111 bool was_ignored_by_handler);
113 protected:
114 // The deprecated WebContentsTester still needs to subclass this.
115 explicit TestWebContents(BrowserContext* browser_context);
117 private:
118 // WebContentsImpl overrides
119 void CreateNewWindow(
120 SiteInstance* source_site_instance,
121 int route_id,
122 int main_frame_route_id,
123 const ViewHostMsg_CreateWindow_Params& params,
124 SessionStorageNamespace* session_storage_namespace) override;
125 void CreateNewWidget(int render_process_id,
126 int route_id,
127 blink::WebPopupType popup_type) override;
128 void CreateNewFullscreenWidget(int render_process_id, int route_id) override;
129 void ShowCreatedWindow(int route_id,
130 WindowOpenDisposition disposition,
131 const gfx::Rect& initial_rect,
132 bool user_gesture) override;
133 void ShowCreatedWidget(int route_id, const gfx::Rect& initial_rect) override;
134 void ShowCreatedFullscreenWidget(int route_id) override;
135 void SaveFrameWithHeaders(const GURL& url,
136 const Referrer& referrer,
137 const std::string& headers) override;
139 RenderViewHostDelegateView* delegate_view_override_;
141 // Expectations for arguments of |SetHistoryOffsetAndLength()|.
142 bool expect_set_history_offset_and_length_;
143 int expect_set_history_offset_and_length_history_offset_;
144 int expect_set_history_offset_and_length_history_length_;
145 std::string save_frame_headers_;
148 } // namespace content
150 #endif // CONTENT_TEST_TEST_WEB_CONTENTS_H_