Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: components/history/core/browser/history_backend_unittest.cc

Issue 2823093002: Make FaviconService::GetRawFaviconForPageURL() select the best candidate among all the icon types (Closed)
Patch Set: Merge branch 'master' into icon_type Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2986 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, 2986 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url,
2987 favicon_base::TOUCH_ICON, 2987 favicon_base::TOUCH_ICON,
2988 GetEdgeSizesSmallAndLarge(), 2988 GetEdgeSizesSmallAndLarge(),
2989 &bitmap_results_out)); 2989 &bitmap_results_out));
2990 2990
2991 EXPECT_EQ(1u, bitmap_results_out.size()); 2991 EXPECT_EQ(1u, bitmap_results_out.size());
2992 EXPECT_EQ(favicon_base::TOUCH_ICON, bitmap_results_out[0].icon_type); 2992 EXPECT_EQ(favicon_base::TOUCH_ICON, bitmap_results_out[0].icon_type);
2993 EXPECT_EQ(icon_url2, bitmap_results_out[0].icon_url); 2993 EXPECT_EQ(icon_url2, bitmap_results_out[0].icon_url);
2994 } 2994 }
2995 2995
2996 // Test that when GetFaviconsFromDB() is called with multiple icon types that
2997 // the best favicon bitmap is selected from among all of the icon types.
2998 TEST_F(HistoryBackendTest, GetFaviconsFromDBMultipleIconTypes) {
2999 const GURL page_url("http://www.google.com/");
3000 const GURL icon_url1("http://www.google.com/icon1.png");
3001 const GURL icon_url2("http://www.google.com/icon2.png");
3002
3003 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data;
3004 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url1,
3005 {CreateBitmap(SK_ColorBLUE, kSmallEdgeSize)});
3006 backend_->SetFavicons(page_url, favicon_base::TOUCH_ICON, icon_url2,
3007 {CreateBitmap(SK_ColorBLUE, kLargeEdgeSize)});
3008
3009 struct TestCase {
3010 int desired_edge_size;
3011 GURL expected_icon_url;
3012 } kTestCases[]{{kSmallEdgeSize, icon_url1}, {kLargeEdgeSize, icon_url2}};
3013
3014 for (const TestCase& test_case : kTestCases) {
3015 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out;
3016 backend_->GetFaviconsForURL(
3017 page_url, favicon_base::FAVICON | favicon_base::TOUCH_ICON,
3018 {test_case.desired_edge_size}, &bitmap_results_out);
3019
3020 ASSERT_EQ(1u, bitmap_results_out.size());
3021 EXPECT_EQ(test_case.expected_icon_url, bitmap_results_out[0].icon_url);
3022 }
3023 }
3024
2996 // Test that GetFaviconsFromDB() correctly sets the expired flag for bitmap 3025 // Test that GetFaviconsFromDB() correctly sets the expired flag for bitmap
2997 // reults. 3026 // reults.
2998 TEST_F(HistoryBackendTest, GetFaviconsFromDBExpired) { 3027 TEST_F(HistoryBackendTest, GetFaviconsFromDBExpired) {
2999 const GURL page_url("http://www.google.com/"); 3028 const GURL page_url("http://www.google.com/");
3000 const GURL icon_url("http://www.google.com/icon.png"); 3029 const GURL icon_url("http://www.google.com/icon.png");
3001 3030
3002 std::vector<unsigned char> data; 3031 std::vector<unsigned char> data;
3003 data.push_back('a'); 3032 data.push_back('a');
3004 scoped_refptr<base::RefCountedBytes> bitmap_data( 3033 scoped_refptr<base::RefCountedBytes> bitmap_data(
3005 base::RefCountedBytes::TakeVector(&data)); 3034 base::RefCountedBytes::TakeVector(&data));
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 backend_->QueryMostVisitedURLs(100, 100, &most_visited); 3881 backend_->QueryMostVisitedURLs(100, 100, &most_visited);
3853 3882
3854 const base::string16 kSomeTitle; // Ignored by equality operator. 3883 const base::string16 kSomeTitle; // Ignored by equality operator.
3855 EXPECT_THAT( 3884 EXPECT_THAT(
3856 most_visited, 3885 most_visited,
3857 ElementsAre(MostVisitedURL(GURL("http://example1.com"), kSomeTitle), 3886 ElementsAre(MostVisitedURL(GURL("http://example1.com"), kSomeTitle),
3858 MostVisitedURL(GURL("http://example5.com"), kSomeTitle))); 3887 MostVisitedURL(GURL("http://example5.com"), kSomeTitle)));
3859 } 3888 }
3860 3889
3861 } // namespace history 3890 } // namespace history
OLDNEW
« no previous file with comments | « components/favicon/core/favicon_service.h ('k') | components/history/core/browser/history_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698