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

Unified Diff: content/test/test_web_contents.cc

Issue 2697803003: Improve test coverage for ContentFaviconDriver (Closed)
Patch Set: Minor test renames. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/test_web_contents.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/test_web_contents.cc
diff --git a/content/test/test_web_contents.cc b/content/test/test_web_contents.cc
index 3436003093b8a7b024580f9e7d5344dd4783205b..4cfe82699ba10f377d85095828f75bf77cdb911d 100644
--- a/content/test/test_web_contents.cc
+++ b/content/test/test_web_contents.cc
@@ -93,7 +93,10 @@ int TestWebContents::DownloadImage(const GURL& url,
bool bypass_cache,
const ImageDownloadCallback& callback) {
static int g_next_image_download_id = 0;
- return ++g_next_image_download_id;
+ ++g_next_image_download_id;
+ pending_image_downloads_[url].emplace_back(g_next_image_download_id,
+ callback);
+ return g_next_image_download_id;
}
void TestWebContents::TestDidNavigate(RenderFrameHost* render_frame_host,
@@ -186,6 +189,24 @@ const std::string& TestWebContents::GetSaveFrameHeaders() {
return save_frame_headers_;
}
+bool TestWebContents::HasPendingDownloadImage(const GURL& url) {
+ return !pending_image_downloads_[url].empty();
+}
+
+bool TestWebContents::TestDidDownloadImage(
+ const GURL& url,
+ int http_status_code,
+ const std::vector<SkBitmap>& bitmaps,
+ const std::vector<gfx::Size>& original_bitmap_sizes) {
+ if (!HasPendingDownloadImage(url))
+ return false;
+ int id = pending_image_downloads_[url].front().first;
+ ImageDownloadCallback callback = pending_image_downloads_[url].front().second;
+ pending_image_downloads_[url].pop_front();
+ callback.Run(id, http_status_code, url, bitmaps, original_bitmap_sizes);
+ return true;
+}
+
bool TestWebContents::CrossProcessNavigationPending() {
if (IsBrowserSideNavigationEnabled()) {
return GetRenderManager()->speculative_render_frame_host_ != nullptr;
« 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