| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/favicon/core/large_icon_service.h" | 5 #include "components/favicon/core/large_icon_service.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/task/cancelable_task_tracker.h" | 15 #include "base/task/cancelable_task_tracker.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "components/favicon/core/favicon_client.h" | 17 #include "components/favicon/core/favicon_client.h" |
| 18 #include "components/favicon/core/favicon_service.h" | 18 #include "components/favicon/core/favicon_service.h" |
| 19 #include "components/favicon_base/fallback_icon_style.h" | 19 #include "components/favicon_base/fallback_icon_style.h" |
| 20 #include "components/favicon_base/favicon_types.h" | 20 #include "components/favicon_base/favicon_types.h" |
| 21 #include "components/image_fetcher/image_fetcher.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
| 23 #include "third_party/skia/include/core/SkColor.h" | 24 #include "third_party/skia/include/core/SkColor.h" |
| 24 #include "ui/gfx/codec/png_codec.h" | 25 #include "ui/gfx/codec/png_codec.h" |
| 25 #include "ui/gfx/geometry/size.h" | 26 #include "ui/gfx/geometry/size.h" |
| 26 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
| 27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 28 | 29 |
| 29 namespace favicon { | 30 namespace favicon { |
| 30 namespace { | 31 namespace { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 result.pixel_size = gfx::Size(w, h); | 51 result.pixel_size = gfx::Size(w, h); |
| 51 result.icon_url = GURL(kDummyIconUrl); | 52 result.icon_url = GURL(kDummyIconUrl); |
| 52 result.icon_type = favicon_base::TOUCH_ICON; | 53 result.icon_type = favicon_base::TOUCH_ICON; |
| 53 CHECK(result.is_valid()); | 54 CHECK(result.is_valid()); |
| 54 return result; | 55 return result; |
| 55 } | 56 } |
| 56 | 57 |
| 57 // A mock FaviconService that emits pre-programmed response. | 58 // A mock FaviconService that emits pre-programmed response. |
| 58 class MockFaviconService : public FaviconService { | 59 class MockFaviconService : public FaviconService { |
| 59 public: | 60 public: |
| 60 MockFaviconService() : FaviconService(nullptr, nullptr) { | 61 MockFaviconService() : FaviconService(nullptr, nullptr, nullptr) { |
| 61 } | 62 } |
| 62 | 63 |
| 63 ~MockFaviconService() override { | 64 ~MockFaviconService() override { |
| 64 } | 65 } |
| 65 | 66 |
| 66 base::CancelableTaskTracker::TaskId GetLargestRawFaviconForPageURL( | 67 base::CancelableTaskTracker::TaskId GetLargestRawFaviconForPageURL( |
| 67 const GURL& page_url, | 68 const GURL& page_url, |
| 68 const std::vector<int>& icon_types, | 69 const std::vector<int>& icon_types, |
| 69 int minimum_size_in_pixels, | 70 int minimum_size_in_pixels, |
| 70 const favicon_base::FaviconRawBitmapCallback& callback, | 71 const favicon_base::FaviconRawBitmapCallback& callback, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 32, | 280 32, |
| 280 24, | 281 24, |
| 281 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), | 282 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), |
| 282 &cancelable_task_tracker_); | 283 &cancelable_task_tracker_); |
| 283 base::RunLoop().RunUntilIdle(); | 284 base::RunLoop().RunUntilIdle(); |
| 284 EXPECT_TRUE(is_callback_invoked_); | 285 EXPECT_TRUE(is_callback_invoked_); |
| 285 } | 286 } |
| 286 | 287 |
| 287 } // namespace | 288 } // namespace |
| 288 } // namespace favicon | 289 } // namespace favicon |
| OLD | NEW |