| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/doodle/doodle_service.h" | 5 #include "components/doodle/doodle_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 15 #include "base/test/mock_callback.h" | 15 #include "base/test/mock_callback.h" |
| 16 #include "base/test/simple_test_tick_clock.h" | 16 #include "base/test/simple_test_tick_clock.h" |
| 17 #include "base/test/test_mock_time_task_runner.h" | 17 #include "base/test/test_mock_time_task_runner.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "components/image_fetcher/core/image_fetcher.h" | 20 #include "components/image_fetcher/core/image_fetcher.h" |
| 21 #include "components/image_fetcher/core/request_metadata.h" | 21 #include "components/image_fetcher/core/request_metadata.h" |
| 22 #include "components/prefs/testing_pref_service.h" | 22 #include "components/prefs/testing_pref_service.h" |
| 23 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.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 "ui/gfx/image/image_unittest_util.h" | 28 #include "ui/gfx/image/image_unittest_util.h" |
| 28 | 29 |
| 29 using image_fetcher::ImageFetcher; | 30 using image_fetcher::ImageFetcher; |
| 30 using image_fetcher::RequestMetadata; | 31 using image_fetcher::RequestMetadata; |
| 31 using testing::_; | 32 using testing::_; |
| 32 using testing::Eq; | 33 using testing::Eq; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // Ignored. | 88 // Ignored. |
| 88 } | 89 } |
| 89 | 90 |
| 90 void SetDesiredImageFrameSize(const gfx::Size&) override { | 91 void SetDesiredImageFrameSize(const gfx::Size&) override { |
| 91 // Ignored. | 92 // Ignored. |
| 92 } | 93 } |
| 93 | 94 |
| 94 void StartOrQueueNetworkRequest( | 95 void StartOrQueueNetworkRequest( |
| 95 const std::string& id, | 96 const std::string& id, |
| 96 const GURL& url, | 97 const GURL& url, |
| 97 const ImageFetcherCallback& callback) override { | 98 const ImageFetcherCallback& callback, |
| 99 const net::NetworkTrafficAnnotationTag&) override { |
| 98 // For simplicity, the fake doesn't support multiple concurrent requests. | 100 // For simplicity, the fake doesn't support multiple concurrent requests. |
| 99 DCHECK(!HasPendingRequest()); | 101 DCHECK(!HasPendingRequest()); |
| 100 | 102 |
| 101 pending_id_ = id; | 103 pending_id_ = id; |
| 102 pending_url_ = url; | 104 pending_url_ = url; |
| 103 pending_callback_ = callback; | 105 pending_callback_ = callback; |
| 104 } | 106 } |
| 105 | 107 |
| 106 image_fetcher::ImageDecoder* GetImageDecoder() override { | 108 image_fetcher::ImageDecoder* GetImageDecoder() override { |
| 107 NOTREACHED(); | 109 NOTREACHED(); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 // large image. | 736 // large image. |
| 735 EXPECT_EQ(config.large_cta_image->url, image_fetcher()->pending_url()); | 737 EXPECT_EQ(config.large_cta_image->url, image_fetcher()->pending_url()); |
| 736 | 738 |
| 737 EXPECT_CALL(callback, Run(Not(IsEmptyImage()))); | 739 EXPECT_CALL(callback, Run(Not(IsEmptyImage()))); |
| 738 gfx::Image image = gfx::test::CreateImage(1, 1); | 740 gfx::Image image = gfx::test::CreateImage(1, 1); |
| 739 ASSERT_TRUE(image_fetcher()->HasPendingRequest()); | 741 ASSERT_TRUE(image_fetcher()->HasPendingRequest()); |
| 740 image_fetcher()->RespondToPendingRequest(image); | 742 image_fetcher()->RespondToPendingRequest(image); |
| 741 } | 743 } |
| 742 | 744 |
| 743 } // namespace doodle | 745 } // namespace doodle |
| OLD | NEW |