OLD | NEW |
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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 typedef base::hash_map<std::string, ImageData> EntryMap; | 43 typedef base::hash_map<std::string, ImageData> EntryMap; |
44 | 44 |
45 void AddEntry(const ImageData& d, EntryMap* map) { (*map)[d.url()] = d; } | 45 void AddEntry(const ImageData& d, EntryMap* map) { (*map)[d.url()] = d; } |
46 | 46 |
47 class MockImageFetcher : public ImageFetcher { | 47 class MockImageFetcher : public ImageFetcher { |
48 public: | 48 public: |
49 MockImageFetcher() {} | 49 MockImageFetcher() {} |
50 virtual ~MockImageFetcher() {} | 50 virtual ~MockImageFetcher() {} |
51 MOCK_METHOD3(StartOrQueueNetworkRequest, | 51 MOCK_METHOD3(StartOrQueueNetworkRequest, |
52 void(const std::string&, const GURL&, | 52 void(const std::string&, |
53 base::Callback<void(const std::string&, | 53 const GURL&, |
54 const gfx::Image&)>)); | 54 const ImageFetcherCallback&)); |
55 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*)); | 55 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*)); |
56 MOCK_METHOD1(SetDataUseServiceName, void(DataUseServiceName)); | 56 MOCK_METHOD1(SetDataUseServiceName, void(DataUseServiceName)); |
57 MOCK_METHOD1(SetDesiredImageFrameSize, void(const gfx::Size&)); | 57 MOCK_METHOD1(SetDesiredImageFrameSize, void(const gfx::Size&)); |
58 MOCK_METHOD0(GetImageDecoder, image_fetcher::ImageDecoder*()); | 58 MOCK_METHOD0(GetImageDecoder, image_fetcher::ImageDecoder*()); |
59 }; | 59 }; |
60 | 60 |
61 class ImageManagerTest : public testing::Test { | 61 class ImageManagerTest : public testing::Test { |
62 public: | 62 public: |
63 ImageManagerTest() | 63 ImageManagerTest() |
64 : mock_image_fetcher_(NULL), | 64 : mock_image_fetcher_(NULL), |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 image_manager_->GetImageForURL(GURL(kTestUrl1), | 216 image_manager_->GetImageForURL(GURL(kTestUrl1), |
217 base::Bind(&ImageManagerTest::OnImageAvailable, | 217 base::Bind(&ImageManagerTest::OnImageAvailable, |
218 base::Unretained(this), &run_loop)); | 218 base::Unretained(this), &run_loop)); |
219 run_loop.Run(); | 219 run_loop.Run(); |
220 | 220 |
221 EXPECT_EQ(0, num_callback_null_called_); | 221 EXPECT_EQ(0, num_callback_null_called_); |
222 EXPECT_EQ(1, num_callback_valid_called_); | 222 EXPECT_EQ(1, num_callback_valid_called_); |
223 } | 223 } |
224 | 224 |
225 } // namespace suggestions | 225 } // namespace suggestions |
OLD | NEW |