| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 | 2037 |
| 2038 // |page_url| should still have a single favicon bitmap. The bitmap data | 2038 // |page_url| should still have a single favicon bitmap. The bitmap data |
| 2039 // should be updated. | 2039 // should be updated. |
| 2040 icon_mappings.clear(); | 2040 icon_mappings.clear(); |
| 2041 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, | 2041 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, |
| 2042 &icon_mappings)); | 2042 &icon_mappings)); |
| 2043 EXPECT_EQ(1u, icon_mappings.size()); | 2043 EXPECT_EQ(1u, icon_mappings.size()); |
| 2044 EXPECT_EQ(icon_url, icon_mappings[0].icon_url); | 2044 EXPECT_EQ(icon_url, icon_mappings[0].icon_url); |
| 2045 | 2045 |
| 2046 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap)); | 2046 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap)); |
| 2047 EXPECT_NE(base::Time(), favicon_bitmap.last_updated); | 2047 EXPECT_EQ(base::Time(), favicon_bitmap.last_updated); |
| 2048 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data)); | 2048 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data)); |
| 2049 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); | 2049 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); |
| 2050 } | 2050 } |
| 2051 | 2051 |
| 2052 // Test calling MergeFavicon() when |page_url| is known to the database. | 2052 // Test calling MergeFavicon() when |page_url| is known to the database. |
| 2053 TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { | 2053 TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { |
| 2054 GURL page_url("http://www.google.com"); | 2054 GURL page_url("http://www.google.com"); |
| 2055 GURL icon_url1("http:/www.google.com/favicon.ico"); | 2055 GURL icon_url1("http:/www.google.com/favicon.ico"); |
| 2056 GURL icon_url2("http://www.google.com/favicon2.ico"); | 2056 GURL icon_url2("http://www.google.com/favicon2.ico"); |
| 2057 std::vector<SkBitmap> bitmaps; | 2057 std::vector<SkBitmap> bitmaps; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2105 page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kSmallSize); | 2105 page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kSmallSize); |
| 2106 | 2106 |
| 2107 // The small favicon bitmap at |icon_url1| should be overwritten. | 2107 // The small favicon bitmap at |icon_url1| should be overwritten. |
| 2108 icon_mappings.clear(); | 2108 icon_mappings.clear(); |
| 2109 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, | 2109 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, |
| 2110 &icon_mappings)); | 2110 &icon_mappings)); |
| 2111 EXPECT_EQ(1u, icon_mappings.size()); | 2111 EXPECT_EQ(1u, icon_mappings.size()); |
| 2112 EXPECT_EQ(icon_url1, icon_mappings[0].icon_url); | 2112 EXPECT_EQ(icon_url1, icon_mappings[0].icon_url); |
| 2113 | 2113 |
| 2114 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap)); | 2114 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap)); |
| 2115 EXPECT_NE(base::Time(), favicon_bitmap.last_updated); | 2115 EXPECT_EQ(base::Time(), favicon_bitmap.last_updated); |
| 2116 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data)); | 2116 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data)); |
| 2117 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); | 2117 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); |
| 2118 | 2118 |
| 2119 // 3) Merge favicon for the same icon URL, but a pixel size for which there is | 2119 // 3) Merge favicon for the same icon URL, but a pixel size for which there is |
| 2120 // no favicon bitmap. | 2120 // no favicon bitmap. |
| 2121 data[0] = 'c'; | 2121 data[0] = 'c'; |
| 2122 bitmap_data = new base::RefCountedBytes(data); | 2122 bitmap_data = new base::RefCountedBytes(data); |
| 2123 backend_->MergeFavicon( | 2123 backend_->MergeFavicon( |
| 2124 page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kTinySize); | 2124 page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kTinySize); |
| 2125 | 2125 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2223 data.push_back('b'); | 2223 data.push_back('b'); |
| 2224 bitmap_data = new base::RefCountedBytes(data); | 2224 bitmap_data = new base::RefCountedBytes(data); |
| 2225 backend_->MergeFavicon( | 2225 backend_->MergeFavicon( |
| 2226 page_url3, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize); | 2226 page_url3, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize); |
| 2227 | 2227 |
| 2228 favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( | 2228 favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( |
| 2229 icon_url, favicon_base::FAVICON, NULL); | 2229 icon_url, favicon_base::FAVICON, NULL); |
| 2230 EXPECT_NE(0, favicon_id); | 2230 EXPECT_NE(0, favicon_id); |
| 2231 | 2231 |
| 2232 EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap)); | 2232 EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap)); |
| 2233 EXPECT_NE(base::Time(), favicon_bitmap.last_updated); | 2233 EXPECT_EQ(base::Time(), favicon_bitmap.last_updated); |
| 2234 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data)); | 2234 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data)); |
| 2235 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); | 2235 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); |
| 2236 | 2236 |
| 2237 // |icon_url| should be mapped to all three page URLs. | 2237 // |icon_url| should be mapped to all three page URLs. |
| 2238 icon_mappings.clear(); | 2238 icon_mappings.clear(); |
| 2239 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url1, | 2239 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url1, |
| 2240 &icon_mappings)); | 2240 &icon_mappings)); |
| 2241 EXPECT_EQ(1u, icon_mappings.size()); | 2241 EXPECT_EQ(1u, icon_mappings.size()); |
| 2242 EXPECT_EQ(favicon_id, icon_mappings[0].icon_id); | 2242 EXPECT_EQ(favicon_id, icon_mappings[0].icon_id); |
| 2243 | 2243 |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3328 // Verify that the second term is no longer returned as result, and also check | 3328 // Verify that the second term is no longer returned as result, and also check |
| 3329 // at the low level that it is gone for good. The term corresponding to the | 3329 // at the low level that it is gone for good. The term corresponding to the |
| 3330 // first URLRow should not be affected. | 3330 // first URLRow should not be affected. |
| 3331 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); | 3331 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); |
| 3332 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); | 3332 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); |
| 3333 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); | 3333 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); |
| 3334 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); | 3334 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
| 3335 } | 3335 } |
| 3336 | 3336 |
| 3337 } // namespace history | 3337 } // namespace history |
| OLD | NEW |