OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp_tiles/icon_cacher_impl.h" | 5 #include "components/ntp_tiles/icon_cacher_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "components/favicon/core/favicon_client.h" | 13 #include "components/favicon/core/favicon_client.h" |
14 #include "components/favicon/core/favicon_service.h" | 14 #include "components/favicon/core/favicon_service_impl.h" |
15 #include "components/favicon/core/favicon_util.h" | 15 #include "components/favicon/core/favicon_util.h" |
16 #include "components/history/core/browser/history_database_params.h" | 16 #include "components/history/core/browser/history_database_params.h" |
17 #include "components/history/core/browser/history_service.h" | 17 #include "components/history/core/browser/history_service.h" |
18 #include "components/image_fetcher/image_fetcher.h" | 18 #include "components/image_fetcher/image_fetcher.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/gfx/image/image_unittest_util.h" | 21 #include "ui/gfx/image/image_unittest_util.h" |
22 | 22 |
23 using ::testing::_; | 23 using ::testing::_; |
24 using ::testing::InSequence; | 24 using ::testing::InSequence; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 &tracker); | 81 &tracker); |
82 loop.Run(); | 82 loop.Run(); |
83 return is_cached; | 83 return is_cached; |
84 } | 84 } |
85 | 85 |
86 base::MessageLoop message_loop_; | 86 base::MessageLoop message_loop_; |
87 PopularSites::Site site_; | 87 PopularSites::Site site_; |
88 std::unique_ptr<MockImageFetcher> image_fetcher_; | 88 std::unique_ptr<MockImageFetcher> image_fetcher_; |
89 base::ScopedTempDir history_dir_; | 89 base::ScopedTempDir history_dir_; |
90 history::HistoryService history_service_; | 90 history::HistoryService history_service_; |
91 favicon::FaviconService favicon_service_; | 91 favicon::FaviconServiceImpl favicon_service_; |
92 }; | 92 }; |
93 | 93 |
94 template <typename Fn> | 94 template <typename Fn> |
95 base::Callback<Fn> BindMockFunction(MockFunction<Fn>* function) { | 95 base::Callback<Fn> BindMockFunction(MockFunction<Fn>* function) { |
96 return base::Bind(&MockFunction<Fn>::Call, base::Unretained(function)); | 96 return base::Bind(&MockFunction<Fn>::Call, base::Unretained(function)); |
97 } | 97 } |
98 | 98 |
99 ACTION(FailFetch) { | 99 ACTION(FailFetch) { |
100 base::ThreadTaskRunnerHandle::Get()->PostTask( | 100 base::ThreadTaskRunnerHandle::Get()->PostTask( |
101 FROM_HERE, base::Bind(arg2, arg0, gfx::Image())); | 101 FROM_HERE, base::Bind(arg2, arg0, gfx::Image())); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 IconCacherImpl cacher(&favicon_service_, std::move(image_fetcher_)); | 191 IconCacherImpl cacher(&favicon_service_, std::move(image_fetcher_)); |
192 cacher.StartFetch(site_, BindMockFunction(&done)); | 192 cacher.StartFetch(site_, BindMockFunction(&done)); |
193 loop.Run(); | 193 loop.Run(); |
194 EXPECT_FALSE(IconIsCachedFor(site_.url, favicon_base::FAVICON)); | 194 EXPECT_FALSE(IconIsCachedFor(site_.url, favicon_base::FAVICON)); |
195 EXPECT_FALSE(IconIsCachedFor(site_.url, favicon_base::TOUCH_ICON)); | 195 EXPECT_FALSE(IconIsCachedFor(site_.url, favicon_base::TOUCH_ICON)); |
196 } | 196 } |
197 | 197 |
198 } // namespace | 198 } // namespace |
199 } // namespace ntp_tiles | 199 } // namespace ntp_tiles |
OLD | NEW |