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 "chrome/browser/history/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1915 GetScaleFactors1x2x(), &bitmap_results); | 1915 GetScaleFactors1x2x(), &bitmap_results); |
1916 | 1916 |
1917 EXPECT_EQ(2u, bitmap_results.size()); | 1917 EXPECT_EQ(2u, bitmap_results.size()); |
1918 const chrome::FaviconBitmapResult& first_result = bitmap_results[0]; | 1918 const chrome::FaviconBitmapResult& first_result = bitmap_results[0]; |
1919 const chrome::FaviconBitmapResult& result = | 1919 const chrome::FaviconBitmapResult& result = |
1920 (first_result.pixel_size == kSmallSize) ? first_result | 1920 (first_result.pixel_size == kSmallSize) ? first_result |
1921 : bitmap_results[1]; | 1921 : bitmap_results[1]; |
1922 EXPECT_TRUE(BitmapDataEqual('c', result.bitmap_data)); | 1922 EXPECT_TRUE(BitmapDataEqual('c', result.bitmap_data)); |
1923 } | 1923 } |
1924 | 1924 |
1925 // Tests GetFaviconsForURL with icon_types priority, | |
pkotwicz
2013/10/18 01:29:35
GetFaviconForURL() -> GetLargestFaviconForURL()
| |
1926 TEST_F(HistoryBackendTest, TestGetFaviconsForURLWithIconTypesPriority) { | |
pkotwicz
2013/10/18 01:29:35
Rename test to GetLargestFaviconForURLPriority or
| |
1927 GURL page_url("http://www.google.com"); | |
1928 GURL icon_url("http://www.google.com/favicon.ico"); | |
1929 GURL touch_icon_url("http://wwww.google.com/touch_icon.ico"); | |
1930 | |
1931 std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; | |
1932 std::vector<gfx::Size> favicon_size; | |
1933 favicon_size.push_back(gfx::Size(16, 16)); | |
1934 favicon_size.push_back(gfx::Size(32, 32)); | |
1935 GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data); | |
1936 ASSERT_EQ(2u, favicon_bitmap_data.size()); | |
1937 | |
1938 std::vector<chrome::FaviconBitmapData> touch_icon_bitmap_data; | |
1939 std::vector<gfx::Size> touch_icon_size; | |
1940 touch_icon_size.push_back(gfx::Size(64, 64)); | |
1941 GenerateFaviconBitmapData(icon_url, touch_icon_size, &touch_icon_bitmap_data); | |
1942 ASSERT_EQ(1u, touch_icon_bitmap_data.size()); | |
1943 | |
1944 // Set some preexisting favicons for |page_url|. | |
1945 backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); | |
1946 backend_->SetFavicons(page_url, chrome::TOUCH_ICON, touch_icon_bitmap_data); | |
1947 | |
1948 chrome::FaviconBitmapResult result; | |
1949 std::vector<int> icon_types; | |
1950 icon_types.push_back(chrome::FAVICON); | |
1951 icon_types.push_back(chrome::TOUCH_ICON); | |
1952 | |
pkotwicz
2013/10/18 01:29:35
Nit: No line break here
| |
1953 backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result); | |
1954 | |
1955 // Verify the result icon is 32x32 favicon. | |
1956 EXPECT_EQ(gfx::Size(32, 32), result.pixel_size); | |
1957 EXPECT_EQ(chrome::FAVICON, result.icon_type); | |
1958 | |
1959 // Change Minimal size to 32x32 and verify the 64x64 touch icon returned. | |
1960 backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result); | |
1961 EXPECT_EQ(gfx::Size(64, 64), result.pixel_size); | |
1962 EXPECT_EQ(chrome::TOUCH_ICON, result.icon_type); | |
1963 } | |
1964 | |
1965 // Test the the first types of icon is returned if its size equal to the | |
1966 // second types icon. | |
1967 TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFavicon) { | |
pkotwicz
2013/10/18 01:29:35
Rename test as well
| |
1968 GURL page_url("http://www.google.com"); | |
1969 GURL icon_url("http://www.google.com/favicon.ico"); | |
1970 GURL touch_icon_url("http://wwww.google.com/touch_icon.ico"); | |
1971 | |
1972 std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; | |
1973 std::vector<gfx::Size> favicon_size; | |
1974 favicon_size.push_back(gfx::Size(16, 16)); | |
1975 favicon_size.push_back(gfx::Size(32, 32)); | |
1976 GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data); | |
1977 ASSERT_EQ(2u, favicon_bitmap_data.size()); | |
1978 | |
1979 std::vector<chrome::FaviconBitmapData> touch_icon_bitmap_data; | |
1980 std::vector<gfx::Size> touch_icon_size; | |
1981 touch_icon_size.push_back(gfx::Size(32, 32)); | |
1982 GenerateFaviconBitmapData(icon_url, touch_icon_size, &touch_icon_bitmap_data); | |
1983 ASSERT_EQ(1u, touch_icon_bitmap_data.size()); | |
1984 | |
1985 // Set some preexisting favicons for |page_url|. | |
1986 backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); | |
1987 backend_->SetFavicons(page_url, chrome::TOUCH_ICON, touch_icon_bitmap_data); | |
1988 | |
1989 chrome::FaviconBitmapResult result; | |
1990 std::vector<int> icon_types; | |
1991 icon_types.push_back(chrome::FAVICON); | |
1992 icon_types.push_back(chrome::TOUCH_ICON); | |
1993 | |
pkotwicz
2013/10/18 01:29:35
No line break here either
| |
1994 backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result); | |
1995 | |
1996 // Verify the result icon is 32x32 favicon. | |
1997 EXPECT_EQ(gfx::Size(32, 32), result.pixel_size); | |
1998 EXPECT_EQ(chrome::FAVICON, result.icon_type); | |
1999 | |
2000 // Change minimal size to 32x32 and verify the 32x32 favicon returned. | |
2001 chrome::FaviconBitmapResult result1; | |
2002 backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result1); | |
2003 EXPECT_EQ(gfx::Size(32, 32), result1.pixel_size); | |
2004 EXPECT_EQ(chrome::FAVICON, result1.icon_type); | |
2005 } | |
2006 | |
2007 // Test the favicon is returned if its size is smaller than minimal size, | |
2008 // because it is only one available. | |
2009 TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFaviconEvenItSmaller) { | |
2010 GURL page_url("http://www.google.com"); | |
2011 GURL icon_url("http://www.google.com/favicon.ico"); | |
2012 | |
2013 std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; | |
2014 std::vector<gfx::Size> favicon_size; | |
2015 favicon_size.push_back(gfx::Size(16, 16)); | |
2016 GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data); | |
2017 ASSERT_EQ(1u, favicon_bitmap_data.size()); | |
2018 | |
2019 // Set preexisting favicons for |page_url|. | |
2020 backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); | |
2021 | |
2022 chrome::FaviconBitmapResult result; | |
2023 std::vector<int> icon_types; | |
2024 icon_types.push_back(chrome::FAVICON); | |
2025 icon_types.push_back(chrome::TOUCH_ICON); | |
2026 | |
2027 backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result); | |
2028 | |
2029 // Verify 16x16 icon is returned, even it small than minimal_size. | |
pkotwicz
2013/10/18 01:29:35
Nit: "even though it is smaller than |minimum_size
| |
2030 EXPECT_EQ(gfx::Size(16, 16), result.pixel_size); | |
2031 EXPECT_EQ(chrome::FAVICON, result.icon_type); | |
2032 } | |
2033 | |
1925 // Test UpdateFaviconMapingsAndFetch() when multiple icon types are passed in. | 2034 // Test UpdateFaviconMapingsAndFetch() when multiple icon types are passed in. |
1926 TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) { | 2035 TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) { |
1927 GURL page_url1("http://www.google.com"); | 2036 GURL page_url1("http://www.google.com"); |
1928 GURL page_url2("http://news.google.com"); | 2037 GURL page_url2("http://news.google.com"); |
1929 GURL page_url3("http://mail.google.com"); | 2038 GURL page_url3("http://mail.google.com"); |
1930 GURL icon_urla("http://www.google.com/favicon1.ico"); | 2039 GURL icon_urla("http://www.google.com/favicon1.ico"); |
1931 GURL icon_urlb("http://www.google.com/favicon2.ico"); | 2040 GURL icon_urlb("http://www.google.com/favicon2.ico"); |
1932 GURL icon_urlc("http://www.google.com/favicon3.ico"); | 2041 GURL icon_urlc("http://www.google.com/favicon3.ico"); |
1933 | 2042 |
1934 // |page_url1| is mapped to |icon_urla| which if of type TOUCH_ICON. | 2043 // |page_url1| is mapped to |icon_urla| which if of type TOUCH_ICON. |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2769 // Delete all DTS index databases. | 2878 // Delete all DTS index databases. |
2770 backend_->DeleteFTSIndexDatabases(); | 2879 backend_->DeleteFTSIndexDatabases(); |
2771 EXPECT_FALSE(base::PathExists(db1)); | 2880 EXPECT_FALSE(base::PathExists(db1)); |
2772 EXPECT_FALSE(base::PathExists(db1_wal)); | 2881 EXPECT_FALSE(base::PathExists(db1_wal)); |
2773 EXPECT_FALSE(base::PathExists(db1_journal)); | 2882 EXPECT_FALSE(base::PathExists(db1_journal)); |
2774 EXPECT_FALSE(base::PathExists(db2_symlink)); | 2883 EXPECT_FALSE(base::PathExists(db2_symlink)); |
2775 EXPECT_TRUE(base::PathExists(db2_actual)); // Symlinks shouldn't be followed. | 2884 EXPECT_TRUE(base::PathExists(db2_actual)); // Symlinks shouldn't be followed. |
2776 } | 2885 } |
2777 | 2886 |
2778 } // namespace history | 2887 } // namespace history |
OLD | NEW |