| 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 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/task/cancelable_task_tracker.h" | 14 #include "base/task/cancelable_task_tracker.h" |
| 15 #include "components/favicon/core/favicon_client.h" | 15 #include "components/favicon/core/favicon_client.h" |
| 16 #include "components/favicon/core/favicon_service.h" | 16 #include "components/favicon/core/favicon_service.h" |
| 17 #include "components/favicon_base/fallback_icon_style.h" | 17 #include "components/favicon_base/fallback_icon_style.h" |
| 18 #include "components/favicon_base/favicon_types.h" | 18 #include "components/favicon_base/favicon_types.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 21 #include "third_party/skia/include/core/SkColor.h" | 21 #include "third_party/skia/include/core/SkColor.h" |
| 22 #include "ui/gfx/codec/png_codec.h" | 22 #include "ui/gfx/codec/png_codec.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 EXPECT_EQ(*expected_fallback_icon_style_, | 134 EXPECT_EQ(*expected_fallback_icon_style_, |
| 135 *result.fallback_icon_style); | 135 *result.fallback_icon_style); |
| 136 } | 136 } |
| 137 // Ensure all mock results have been consumed. | 137 // Ensure all mock results have been consumed. |
| 138 EXPECT_FALSE(mock_favicon_service_->HasUnusedResults()); | 138 EXPECT_FALSE(mock_favicon_service_->HasUnusedResults()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 protected: | 141 protected: |
| 142 base::MessageLoopForIO loop_; | 142 base::MessageLoopForIO loop_; |
| 143 | 143 |
| 144 scoped_ptr<MockFaviconService> mock_favicon_service_; | 144 std::unique_ptr<MockFaviconService> mock_favicon_service_; |
| 145 scoped_ptr<TestLargeIconService> large_icon_service_; | 145 std::unique_ptr<TestLargeIconService> large_icon_service_; |
| 146 base::CancelableTaskTracker cancelable_task_tracker_; | 146 base::CancelableTaskTracker cancelable_task_tracker_; |
| 147 | 147 |
| 148 favicon_base::FaviconRawBitmapResult expected_bitmap_; | 148 favicon_base::FaviconRawBitmapResult expected_bitmap_; |
| 149 scoped_ptr<favicon_base::FallbackIconStyle> expected_fallback_icon_style_; | 149 std::unique_ptr<favicon_base::FallbackIconStyle> |
| 150 expected_fallback_icon_style_; |
| 150 | 151 |
| 151 bool is_callback_invoked_; | 152 bool is_callback_invoked_; |
| 152 | 153 |
| 153 private: | 154 private: |
| 154 DISALLOW_COPY_AND_ASSIGN(LargeIconServiceTest); | 155 DISALLOW_COPY_AND_ASSIGN(LargeIconServiceTest); |
| 155 }; | 156 }; |
| 156 | 157 |
| 157 TEST_F(LargeIconServiceTest, SameSize) { | 158 TEST_F(LargeIconServiceTest, SameSize) { |
| 158 mock_favicon_service_->InjectResult(CreateTestBitmap(24, 24, kTestColor)); | 159 mock_favicon_service_->InjectResult(CreateTestBitmap(24, 24, kTestColor)); |
| 159 expected_bitmap_ = CreateTestBitmap(24, 24, kTestColor); | 160 expected_bitmap_ = CreateTestBitmap(24, 24, kTestColor); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 32, | 275 32, |
| 275 24, | 276 24, |
| 276 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), | 277 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), |
| 277 &cancelable_task_tracker_); | 278 &cancelable_task_tracker_); |
| 278 base::MessageLoop::current()->RunUntilIdle(); | 279 base::MessageLoop::current()->RunUntilIdle(); |
| 279 EXPECT_TRUE(is_callback_invoked_); | 280 EXPECT_TRUE(is_callback_invoked_); |
| 280 } | 281 } |
| 281 | 282 |
| 282 } // namespace | 283 } // namespace |
| 283 } // namespace favicon | 284 } // namespace favicon |
| OLD | NEW |