Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Side by Side Diff: content/test/test_web_contents.cc

Issue 2697803003: Improve test coverage for ContentFaviconDriver (Closed)
Patch Set: Minor test renames. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/test/test_web_contents.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/test/test_web_contents.h" 5 #include "content/test/test_web_contents.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/browser/browser_url_handler_impl.h" 9 #include "content/browser/browser_url_handler_impl.h"
10 #include "content/browser/frame_host/cross_process_frame_connector.h" 10 #include "content/browser/frame_host/cross_process_frame_connector.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 rfh->SimulateNavigationStart(url); 86 rfh->SimulateNavigationStart(url);
87 } 87 }
88 } 88 }
89 89
90 int TestWebContents::DownloadImage(const GURL& url, 90 int TestWebContents::DownloadImage(const GURL& url,
91 bool is_favicon, 91 bool is_favicon,
92 uint32_t max_bitmap_size, 92 uint32_t max_bitmap_size,
93 bool bypass_cache, 93 bool bypass_cache,
94 const ImageDownloadCallback& callback) { 94 const ImageDownloadCallback& callback) {
95 static int g_next_image_download_id = 0; 95 static int g_next_image_download_id = 0;
96 return ++g_next_image_download_id; 96 ++g_next_image_download_id;
97 pending_image_downloads_[url].emplace_back(g_next_image_download_id,
98 callback);
99 return g_next_image_download_id;
97 } 100 }
98 101
99 void TestWebContents::TestDidNavigate(RenderFrameHost* render_frame_host, 102 void TestWebContents::TestDidNavigate(RenderFrameHost* render_frame_host,
100 int nav_entry_id, 103 int nav_entry_id,
101 bool did_create_new_entry, 104 bool did_create_new_entry,
102 const GURL& url, 105 const GURL& url,
103 ui::PageTransition transition) { 106 ui::PageTransition transition) {
104 TestDidNavigateWithReferrer(render_frame_host, 107 TestDidNavigateWithReferrer(render_frame_host,
105 nav_entry_id, 108 nav_entry_id,
106 did_create_new_entry, 109 did_create_new_entry,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 params.searchable_form_url = GURL(); 182 params.searchable_form_url = GURL();
180 params.searchable_form_encoding = std::string(); 183 params.searchable_form_encoding = std::string();
181 184
182 rfh->SendNavigateWithParams(&params); 185 rfh->SendNavigateWithParams(&params);
183 } 186 }
184 187
185 const std::string& TestWebContents::GetSaveFrameHeaders() { 188 const std::string& TestWebContents::GetSaveFrameHeaders() {
186 return save_frame_headers_; 189 return save_frame_headers_;
187 } 190 }
188 191
192 bool TestWebContents::HasPendingDownloadImage(const GURL& url) {
193 return !pending_image_downloads_[url].empty();
194 }
195
196 bool TestWebContents::TestDidDownloadImage(
197 const GURL& url,
198 int http_status_code,
199 const std::vector<SkBitmap>& bitmaps,
200 const std::vector<gfx::Size>& original_bitmap_sizes) {
201 if (!HasPendingDownloadImage(url))
202 return false;
203 int id = pending_image_downloads_[url].front().first;
204 ImageDownloadCallback callback = pending_image_downloads_[url].front().second;
205 pending_image_downloads_[url].pop_front();
206 callback.Run(id, http_status_code, url, bitmaps, original_bitmap_sizes);
207 return true;
208 }
209
189 bool TestWebContents::CrossProcessNavigationPending() { 210 bool TestWebContents::CrossProcessNavigationPending() {
190 if (IsBrowserSideNavigationEnabled()) { 211 if (IsBrowserSideNavigationEnabled()) {
191 return GetRenderManager()->speculative_render_frame_host_ != nullptr; 212 return GetRenderManager()->speculative_render_frame_host_ != nullptr;
192 } 213 }
193 return GetRenderManager()->pending_frame_host() != nullptr; 214 return GetRenderManager()->pending_frame_host() != nullptr;
194 } 215 }
195 216
196 bool TestWebContents::CreateRenderViewForRenderManager( 217 bool TestWebContents::CreateRenderViewForRenderManager(
197 RenderViewHost* render_view_host, 218 RenderViewHost* render_view_host,
198 int opener_frame_routing_id, 219 int opener_frame_routing_id,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 int route_id) { 401 int route_id) {
381 } 402 }
382 403
383 void TestWebContents::SaveFrameWithHeaders(const GURL& url, 404 void TestWebContents::SaveFrameWithHeaders(const GURL& url,
384 const Referrer& referrer, 405 const Referrer& referrer,
385 const std::string& headers) { 406 const std::string& headers) {
386 save_frame_headers_ = headers; 407 save_frame_headers_ = headers;
387 } 408 }
388 409
389 } // namespace content 410 } // namespace content
OLDNEW
« no previous file with comments | « content/test/test_web_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698