OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/history/core/browser/history_backend.h" | 5 #include "components/history/core/browser/history_backend.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2987 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, | 2987 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, |
2988 favicon_base::TOUCH_ICON, | 2988 favicon_base::TOUCH_ICON, |
2989 GetEdgeSizesSmallAndLarge(), | 2989 GetEdgeSizesSmallAndLarge(), |
2990 &bitmap_results_out)); | 2990 &bitmap_results_out)); |
2991 | 2991 |
2992 EXPECT_EQ(1u, bitmap_results_out.size()); | 2992 EXPECT_EQ(1u, bitmap_results_out.size()); |
2993 EXPECT_EQ(favicon_base::TOUCH_ICON, bitmap_results_out[0].icon_type); | 2993 EXPECT_EQ(favicon_base::TOUCH_ICON, bitmap_results_out[0].icon_type); |
2994 EXPECT_EQ(icon_url2, bitmap_results_out[0].icon_url); | 2994 EXPECT_EQ(icon_url2, bitmap_results_out[0].icon_url); |
2995 } | 2995 } |
2996 | 2996 |
| 2997 // Test that when GetFaviconsFromDB() is called with multiple icon types that |
| 2998 // the best favicon bitmap is selected from among all of the icon types. |
| 2999 TEST_F(HistoryBackendTest, GetFaviconsFromDBMultipleIconTypes) { |
| 3000 const GURL page_url("http://www.google.com/"); |
| 3001 const GURL icon_url1("http://www.google.com/icon1.png"); |
| 3002 const GURL icon_url2("http://www.google.com/icon2.png"); |
| 3003 |
| 3004 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; |
| 3005 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url1, |
| 3006 {CreateBitmap(SK_ColorBLUE, kSmallEdgeSize)}); |
| 3007 backend_->SetFavicons(page_url, favicon_base::TOUCH_ICON, icon_url2, |
| 3008 {CreateBitmap(SK_ColorBLUE, kLargeEdgeSize)}); |
| 3009 |
| 3010 struct TestCase { |
| 3011 int desired_edge_size; |
| 3012 GURL expected_icon_url; |
| 3013 } kTestCases[]{{kSmallEdgeSize, icon_url1}, {kLargeEdgeSize, icon_url2}}; |
| 3014 |
| 3015 for (const TestCase& test_case : kTestCases) { |
| 3016 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out; |
| 3017 backend_->GetFaviconsForURL( |
| 3018 page_url, favicon_base::FAVICON | favicon_base::TOUCH_ICON, |
| 3019 {test_case.desired_edge_size}, &bitmap_results_out); |
| 3020 |
| 3021 ASSERT_EQ(1u, bitmap_results_out.size()); |
| 3022 EXPECT_EQ(test_case.expected_icon_url, bitmap_results_out[0].icon_url); |
| 3023 } |
| 3024 } |
| 3025 |
2997 // Test that GetFaviconsFromDB() correctly sets the expired flag for bitmap | 3026 // Test that GetFaviconsFromDB() correctly sets the expired flag for bitmap |
2998 // reults. | 3027 // reults. |
2999 TEST_F(HistoryBackendTest, GetFaviconsFromDBExpired) { | 3028 TEST_F(HistoryBackendTest, GetFaviconsFromDBExpired) { |
3000 const GURL page_url("http://www.google.com/"); | 3029 const GURL page_url("http://www.google.com/"); |
3001 const GURL icon_url("http://www.google.com/icon.png"); | 3030 const GURL icon_url("http://www.google.com/icon.png"); |
3002 | 3031 |
3003 std::vector<unsigned char> data; | 3032 std::vector<unsigned char> data; |
3004 data.push_back('a'); | 3033 data.push_back('a'); |
3005 scoped_refptr<base::RefCountedBytes> bitmap_data( | 3034 scoped_refptr<base::RefCountedBytes> bitmap_data( |
3006 base::RefCountedBytes::TakeVector(&data)); | 3035 base::RefCountedBytes::TakeVector(&data)); |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3853 backend_->QueryMostVisitedURLs(100, 100, &most_visited); | 3882 backend_->QueryMostVisitedURLs(100, 100, &most_visited); |
3854 | 3883 |
3855 const base::string16 kSomeTitle; // Ignored by equality operator. | 3884 const base::string16 kSomeTitle; // Ignored by equality operator. |
3856 EXPECT_THAT( | 3885 EXPECT_THAT( |
3857 most_visited, | 3886 most_visited, |
3858 ElementsAre(MostVisitedURL(GURL("http://example1.com"), kSomeTitle), | 3887 ElementsAre(MostVisitedURL(GURL("http://example1.com"), kSomeTitle), |
3859 MostVisitedURL(GURL("http://example5.com"), kSomeTitle))); | 3888 MostVisitedURL(GURL("http://example5.com"), kSomeTitle))); |
3860 } | 3889 } |
3861 | 3890 |
3862 } // namespace history | 3891 } // namespace history |
OLD | NEW |