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

Side by Side Diff: components/suggestions/image_manager_unittest.cc

Issue 1974013002: Replace SkBitmap with gfx::Image in the ImageFetcher API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync again Created 4 years, 7 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/suggestions/image_manager.h" 5 #include "components/suggestions/image_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "components/image_fetcher/image_fetcher.h" 14 #include "components/image_fetcher/image_fetcher.h"
15 #include "components/image_fetcher/image_fetcher_delegate.h" 15 #include "components/image_fetcher/image_fetcher_delegate.h"
16 #include "components/leveldb_proto/proto_database.h" 16 #include "components/leveldb_proto/proto_database.h"
17 #include "components/leveldb_proto/testing/fake_db.h" 17 #include "components/leveldb_proto/testing/fake_db.h"
18 #include "components/suggestions/image_encoder.h" 18 #include "components/suggestions/image_encoder.h"
19 #include "components/suggestions/proto/suggestions.pb.h" 19 #include "components/suggestions/proto/suggestions.pb.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "ui/gfx/image/image.h"
22 #include "ui/gfx/image/image_skia.h" 23 #include "ui/gfx/image/image_skia.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 using ::testing::Return; 26 using ::testing::Return;
26 using ::testing::StrictMock; 27 using ::testing::StrictMock;
27 using ::testing::_; 28 using ::testing::_;
28 29
29 using image_fetcher::ImageFetcher; 30 using image_fetcher::ImageFetcher;
30 using image_fetcher::ImageFetcherDelegate; 31 using image_fetcher::ImageFetcherDelegate;
31 32
32 namespace suggestions { 33 namespace suggestions {
33 34
34 const char kTestUrl1[] = "http://go.com/"; 35 const char kTestUrl1[] = "http://go.com/";
35 const char kTestUrl2[] = "http://goal.com/"; 36 const char kTestUrl2[] = "http://goal.com/";
36 const char kTestImagePath[] = "files/image_decoding/droids.png"; 37 const char kTestImagePath[] = "files/image_decoding/droids.png";
37 const char kInvalidImagePath[] = "files/DOESNOTEXIST"; 38 const char kInvalidImagePath[] = "files/DOESNOTEXIST";
38 39
39 using leveldb_proto::test::FakeDB; 40 using leveldb_proto::test::FakeDB;
40 41
41 typedef base::hash_map<std::string, ImageData> EntryMap; 42 typedef base::hash_map<std::string, ImageData> EntryMap;
42 43
43 void AddEntry(const ImageData& d, EntryMap* map) { (*map)[d.url()] = d; } 44 void AddEntry(const ImageData& d, EntryMap* map) { (*map)[d.url()] = d; }
44 45
45 class MockImageFetcher : public ImageFetcher { 46 class MockImageFetcher : public ImageFetcher {
46 public: 47 public:
47 MockImageFetcher() {} 48 MockImageFetcher() {}
48 virtual ~MockImageFetcher() {} 49 virtual ~MockImageFetcher() {}
49 MOCK_METHOD3(StartOrQueueNetworkRequest, 50 MOCK_METHOD3(StartOrQueueNetworkRequest,
50 void(const GURL&, const GURL&, 51 void(const GURL&, const GURL&,
51 base::Callback<void(const GURL&, const SkBitmap*)>)); 52 base::Callback<void(const GURL&, const gfx::Image&)>));
52 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*)); 53 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*));
53 }; 54 };
54 55
55 class ImageManagerTest : public testing::Test { 56 class ImageManagerTest : public testing::Test {
56 public: 57 public:
57 ImageManagerTest() 58 ImageManagerTest()
58 : mock_image_fetcher_(NULL), 59 : mock_image_fetcher_(NULL),
59 num_callback_null_called_(0), 60 num_callback_null_called_(0),
60 num_callback_valid_called_(0) {} 61 num_callback_valid_called_(0) {}
61 62
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 image_manager_->GetImageForURL(GURL(kTestUrl1), 211 image_manager_->GetImageForURL(GURL(kTestUrl1),
211 base::Bind(&ImageManagerTest::OnImageAvailable, 212 base::Bind(&ImageManagerTest::OnImageAvailable,
212 base::Unretained(this), &run_loop)); 213 base::Unretained(this), &run_loop));
213 run_loop.Run(); 214 run_loop.Run();
214 215
215 EXPECT_EQ(0, num_callback_null_called_); 216 EXPECT_EQ(0, num_callback_null_called_);
216 EXPECT_EQ(1, num_callback_valid_called_); 217 EXPECT_EQ(1, num_callback_valid_called_);
217 } 218 }
218 219
219 } // namespace suggestions 220 } // namespace suggestions
OLDNEW
« no previous file with comments | « components/suggestions/image_manager.cc ('k') | ios/chrome/browser/suggestions/image_fetcher_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698