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" |
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/geometry/size.h" |
22 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
23 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" |
24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
25 | 26 |
26 using ::testing::Return; | 27 using ::testing::Return; |
27 using ::testing::StrictMock; | 28 using ::testing::StrictMock; |
28 using ::testing::_; | 29 using ::testing::_; |
29 | 30 |
30 using image_fetcher::ImageFetcher; | 31 using image_fetcher::ImageFetcher; |
31 using image_fetcher::ImageFetcherDelegate; | 32 using image_fetcher::ImageFetcherDelegate; |
(...skipping 14 matching lines...) Expand all Loading... |
46 class MockImageFetcher : public ImageFetcher { | 47 class MockImageFetcher : public ImageFetcher { |
47 public: | 48 public: |
48 MockImageFetcher() {} | 49 MockImageFetcher() {} |
49 virtual ~MockImageFetcher() {} | 50 virtual ~MockImageFetcher() {} |
50 MOCK_METHOD3(StartOrQueueNetworkRequest, | 51 MOCK_METHOD3(StartOrQueueNetworkRequest, |
51 void(const std::string&, const GURL&, | 52 void(const std::string&, const GURL&, |
52 base::Callback<void(const std::string&, | 53 base::Callback<void(const std::string&, |
53 const gfx::Image&)>)); | 54 const gfx::Image&)>)); |
54 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*)); | 55 MOCK_METHOD1(SetImageFetcherDelegate, void(ImageFetcherDelegate*)); |
55 MOCK_METHOD1(SetDataUseServiceName, void(DataUseServiceName)); | 56 MOCK_METHOD1(SetDataUseServiceName, void(DataUseServiceName)); |
| 57 MOCK_METHOD1(SetDesiredImageFrameSize, void(const gfx::Size&)); |
56 }; | 58 }; |
57 | 59 |
58 class ImageManagerTest : public testing::Test { | 60 class ImageManagerTest : public testing::Test { |
59 public: | 61 public: |
60 ImageManagerTest() | 62 ImageManagerTest() |
61 : mock_image_fetcher_(NULL), | 63 : mock_image_fetcher_(NULL), |
62 num_callback_null_called_(0), | 64 num_callback_null_called_(0), |
63 num_callback_valid_called_(0) {} | 65 num_callback_valid_called_(0) {} |
64 | 66 |
65 void SetUp() override { | 67 void SetUp() override { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 image_manager_->GetImageForURL(GURL(kTestUrl1), | 215 image_manager_->GetImageForURL(GURL(kTestUrl1), |
214 base::Bind(&ImageManagerTest::OnImageAvailable, | 216 base::Bind(&ImageManagerTest::OnImageAvailable, |
215 base::Unretained(this), &run_loop)); | 217 base::Unretained(this), &run_loop)); |
216 run_loop.Run(); | 218 run_loop.Run(); |
217 | 219 |
218 EXPECT_EQ(0, num_callback_null_called_); | 220 EXPECT_EQ(0, num_callback_null_called_); |
219 EXPECT_EQ(1, num_callback_valid_called_); | 221 EXPECT_EQ(1, num_callback_valid_called_); |
220 } | 222 } |
221 | 223 |
222 } // namespace suggestions | 224 } // namespace suggestions |
OLD | NEW |