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

Side by Side Diff: chrome/browser/search/suggestions/image_fetcher_impl_browsertest.cc

Issue 2757643002: components/image_fetcher: Expose RequestMetadata from ImageFetcher (Closed)
Patch Set: logo_bridge 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/image_fetcher/image_fetcher_impl.h" 5 #include "components/image_fetcher/image_fetcher_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ImageFetcherImpl* fetcher = 78 ImageFetcherImpl* fetcher =
79 new ImageFetcherImpl( 79 new ImageFetcherImpl(
80 base::MakeUnique<suggestions::ImageDecoderImpl>(), 80 base::MakeUnique<suggestions::ImageDecoderImpl>(),
81 browser()->profile()->GetRequestContext()); 81 browser()->profile()->GetRequestContext());
82 fetcher->SetImageFetcherDelegate(&delegate_); 82 fetcher->SetImageFetcherDelegate(&delegate_);
83 return fetcher; 83 return fetcher;
84 } 84 }
85 85
86 void OnImageAvailable(base::RunLoop* loop, 86 void OnImageAvailable(base::RunLoop* loop,
87 const std::string& id, 87 const std::string& id,
88 const gfx::Image& image) { 88 const gfx::Image& image,
89 const image_fetcher::RequestMetadata& metadata) {
89 if (!image.IsEmpty()) { 90 if (!image.IsEmpty()) {
90 num_callback_valid_called_++; 91 num_callback_valid_called_++;
91 } else { 92 } else {
92 num_callback_null_called_++; 93 num_callback_null_called_++;
93 } 94 }
94 loop->Quit(); 95 loop->Quit();
95 } 96 }
96 97
97 void StartOrQueueNetworkRequestHelper(const GURL& image_url) { 98 void StartOrQueueNetworkRequestHelper(const GURL& image_url) {
98 std::unique_ptr<ImageFetcherImpl> image_fetcher_(CreateImageFetcher()); 99 std::unique_ptr<ImageFetcherImpl> image_fetcher_(CreateImageFetcher());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 GURL invalid_image_url(test_server_.GetURL(kInvalidImagePath).spec()); 143 GURL invalid_image_url(test_server_.GetURL(kInvalidImagePath).spec());
143 StartOrQueueNetworkRequestHelper(invalid_image_url); 144 StartOrQueueNetworkRequestHelper(invalid_image_url);
144 145
145 EXPECT_EQ(0, num_callback_valid_called_); 146 EXPECT_EQ(0, num_callback_valid_called_);
146 EXPECT_EQ(1, num_callback_null_called_); 147 EXPECT_EQ(1, num_callback_null_called_);
147 EXPECT_EQ(0, delegate_.num_delegate_valid_called()); 148 EXPECT_EQ(0, delegate_.num_delegate_valid_called());
148 EXPECT_EQ(1, delegate_.num_delegate_null_called()); 149 EXPECT_EQ(1, delegate_.num_delegate_null_called());
149 } 150 }
150 151
151 } // namespace suggestions 152 } // namespace suggestions
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/hats/hats_notification_controller_unittest.cc ('k') | chrome/browser/search/thumbnail_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698