OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/favicon/core/favicon_service_impl.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/message_loop/message_loop.h" |
| 11 #include "components/favicon/core/favicon_client.h" |
| 12 #include "components/history/core/browser/history_service.h" |
| 13 #include "components/history/core/test/history_service_test_util.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 |
| 16 namespace favicon { |
| 17 namespace { |
| 18 |
| 19 TEST(FaviconServiceImplTest, ShouldCacheUnableToDownloadFavicons) { |
| 20 base::MessageLoop message_loop; |
| 21 base::ScopedTempDir history_dir; |
| 22 CHECK(history_dir.CreateUniqueTempDir()); |
| 23 std::unique_ptr<history::HistoryService> history_service = |
| 24 history::CreateHistoryService(history_dir.GetPath(), /*create_db=*/false); |
| 25 FaviconServiceImpl favicon_service( |
| 26 /*favicon_client=*/nullptr, history_service.get()); |
| 27 |
| 28 const GURL icon1("http://www.google.com/favicon.ico"); |
| 29 const GURL icon2("http://www.youtube.com/favicon.ico"); |
| 30 EXPECT_FALSE(favicon_service.WasUnableToDownloadFavicon(icon1)); |
| 31 EXPECT_FALSE(favicon_service.WasUnableToDownloadFavicon(icon2)); |
| 32 |
| 33 favicon_service.UnableToDownloadFavicon(icon1); |
| 34 EXPECT_TRUE(favicon_service.WasUnableToDownloadFavicon(icon1)); |
| 35 EXPECT_FALSE(favicon_service.WasUnableToDownloadFavicon(icon2)); |
| 36 |
| 37 favicon_service.UnableToDownloadFavicon(icon2); |
| 38 EXPECT_TRUE(favicon_service.WasUnableToDownloadFavicon(icon2)); |
| 39 |
| 40 favicon_service.ClearUnableToDownloadFavicons(); |
| 41 EXPECT_FALSE(favicon_service.WasUnableToDownloadFavicon(icon1)); |
| 42 EXPECT_FALSE(favicon_service.WasUnableToDownloadFavicon(icon2)); |
| 43 } |
| 44 |
| 45 } // namespace |
| 46 } // namespace favicon |
OLD | NEW |