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 <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/test/mock_callback.h" | 14 #include "base/test/mock_callback.h" |
| 15 #include "base/test/scoped_task_environment.h" |
15 #include "base/test/test_simple_task_runner.h" | 16 #include "base/test/test_simple_task_runner.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
17 #include "components/favicon/core/favicon_client.h" | 18 #include "components/favicon/core/favicon_client.h" |
18 #include "components/favicon/core/favicon_service_impl.h" | 19 #include "components/favicon/core/favicon_service_impl.h" |
19 #include "components/favicon/core/favicon_util.h" | 20 #include "components/favicon/core/favicon_util.h" |
20 #include "components/history/core/browser/history_database_params.h" | 21 #include "components/history/core/browser/history_database_params.h" |
21 #include "components/history/core/browser/history_service.h" | 22 #include "components/history/core/browser/history_service.h" |
22 #include "components/image_fetcher/core/image_decoder.h" | 23 #include "components/image_fetcher/core/image_decoder.h" |
23 #include "components/image_fetcher/core/image_fetcher.h" | 24 #include "components/image_fetcher/core/image_fetcher.h" |
24 #include "components/image_fetcher/core/request_metadata.h" | 25 #include "components/image_fetcher/core/request_metadata.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 loop->Quit(); | 171 loop->Quit(); |
171 }, | 172 }, |
172 &image, &loop), | 173 &image, &loop), |
173 &tracker); | 174 &tracker); |
174 loop.Run(); | 175 loop.Run(); |
175 return image; | 176 return image; |
176 } | 177 } |
177 | 178 |
178 void WaitForTasksToFinish() { task_runner_->RunUntilIdle(); } | 179 void WaitForTasksToFinish() { task_runner_->RunUntilIdle(); } |
179 | 180 |
180 base::MessageLoop message_loop_; | 181 base::test::ScopedTaskEnvironment scoped_task_environment_; |
181 PopularSites::Site site_; | 182 PopularSites::Site site_; |
182 std::unique_ptr<MockImageFetcher> image_fetcher_; | 183 std::unique_ptr<MockImageFetcher> image_fetcher_; |
183 std::unique_ptr<MockImageDecoder> image_decoder_; | 184 std::unique_ptr<MockImageDecoder> image_decoder_; |
184 base::ScopedTempDir history_dir_; | 185 base::ScopedTempDir history_dir_; |
185 history::HistoryService history_service_; | 186 history::HistoryService history_service_; |
186 favicon::FaviconServiceImpl favicon_service_; | 187 favicon::FaviconServiceImpl favicon_service_; |
187 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 188 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
188 NiceMock<MockResourceDelegate> mock_resource_delegate_; | 189 NiceMock<MockResourceDelegate> mock_resource_delegate_; |
189 }; | 190 }; |
190 | 191 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 Eq(gfx::Size(64, 64))); // Compares dimensions, not objects. | 348 Eq(gfx::Size(64, 64))); // Compares dimensions, not objects. |
348 | 349 |
349 // Let the fetcher continue and wait for the second call of the callback. | 350 // Let the fetcher continue and wait for the second call of the callback. |
350 fetch_loop.Run(); // Wait for the updated image. | 351 fetch_loop.Run(); // Wait for the updated image. |
351 EXPECT_THAT(GetCachedIconFor(site_.url, favicon_base::TOUCH_ICON).Size(), | 352 EXPECT_THAT(GetCachedIconFor(site_.url, favicon_base::TOUCH_ICON).Size(), |
352 Eq(gfx::Size(128, 128))); // Compares dimensions, not objects. | 353 Eq(gfx::Size(128, 128))); // Compares dimensions, not objects. |
353 } | 354 } |
354 | 355 |
355 } // namespace | 356 } // namespace |
356 } // namespace ntp_tiles | 357 } // namespace ntp_tiles |
OLD | NEW |