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

Side by Side Diff: chrome/browser/history/history_backend_unittest.cc

Issue 531493002: Move encoding SkBitmaps to PNG out of FaviconService::SetFavicons() and onto the history thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 20 matching lines...) Expand all
31 #include "chrome/common/importer/imported_favicon_usage.h" 31 #include "chrome/common/importer/imported_favicon_usage.h"
32 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
33 #include "components/history/core/browser/in_memory_database.h" 33 #include "components/history/core/browser/in_memory_database.h"
34 #include "components/history/core/browser/keyword_search_term.h" 34 #include "components/history/core/browser/keyword_search_term.h"
35 #include "components/history/core/test/history_client_fake_bookmarks.h" 35 #include "components/history/core/test/history_client_fake_bookmarks.h"
36 #include "content/public/browser/notification_details.h" 36 #include "content/public/browser/notification_details.h"
37 #include "content/public/browser/notification_source.h" 37 #include "content/public/browser/notification_source.h"
38 #include "content/public/test/test_browser_thread.h" 38 #include "content/public/test/test_browser_thread.h"
39 #include "testing/gmock/include/gmock/gmock.h" 39 #include "testing/gmock/include/gmock/gmock.h"
40 #include "testing/gtest/include/gtest/gtest.h" 40 #include "testing/gtest/include/gtest/gtest.h"
41 #include "third_party/skia/include/core/SkBitmap.h"
42 #include "ui/gfx/codec/png_codec.h"
41 #include "url/gurl.h" 43 #include "url/gurl.h"
42 44
43 using base::Time; 45 using base::Time;
44 46
45 // This file only tests functionality where it is most convenient to call the 47 // This file only tests functionality where it is most convenient to call the
46 // backend directly. Most of the history backend functions are tested by the 48 // backend directly. Most of the history backend functions are tested by the
47 // history unit test. Because of the elaborate callbacks involved, this is no 49 // history unit test. Because of the elaborate callbacks involved, this is no
48 // harder than calling it directly for many things. 50 // harder than calling it directly for many things.
49 51
50 namespace { 52 namespace {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 int GetTransition(const GURL& url) { 261 int GetTransition(const GURL& url) {
260 if (!url.is_valid()) 262 if (!url.is_valid())
261 return 0; 263 return 0;
262 URLRow row; 264 URLRow row;
263 URLID id = backend_->db()->GetRowForURL(url, &row); 265 URLID id = backend_->db()->GetRowForURL(url, &row);
264 VisitVector visits; 266 VisitVector visits;
265 EXPECT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); 267 EXPECT_TRUE(backend_->db()->GetVisitsForURL(id, &visits));
266 return visits[0].transition; 268 return visits[0].transition;
267 } 269 }
268 270
269 // Returns a vector with the small edge size.
270 const std::vector<int> GetEdgeSizesSmall() {
271 std::vector<int> sizes_small;
272 sizes_small.push_back(kSmallEdgeSize);
273 return sizes_small;
274 }
275
276 // Returns a vector with the large edge size.
277 const std::vector<int> GetEdgeSizesLarge() {
278 std::vector<int> sizes_large;
279 sizes_large.push_back(kLargeEdgeSize);
280 return sizes_large;
281 }
282
283 // Returns a vector with the small and large edge sizes. 271 // Returns a vector with the small and large edge sizes.
284 const std::vector<int> GetEdgeSizesSmallAndLarge() { 272 const std::vector<int> GetEdgeSizesSmallAndLarge() {
285 std::vector<int> sizes_small_and_large; 273 std::vector<int> sizes_small_and_large;
286 sizes_small_and_large.push_back(kSmallEdgeSize); 274 sizes_small_and_large.push_back(kSmallEdgeSize);
287 sizes_small_and_large.push_back(kLargeEdgeSize); 275 sizes_small_and_large.push_back(kLargeEdgeSize);
288 return sizes_small_and_large; 276 return sizes_small_and_large;
289 } 277 }
290 278
291 // Returns a vector with the tiny, small, and large edge sizes.
292 const std::vector<int> GetEdgeSizesTinySmallAndLarge() {
293 std::vector<int> sizes_tiny_small_and_large;
294 sizes_tiny_small_and_large.push_back(kTinyEdgeSize);
295 sizes_tiny_small_and_large.push_back(kSmallEdgeSize);
296 sizes_tiny_small_and_large.push_back(kLargeEdgeSize);
297 return sizes_tiny_small_and_large;
298 }
299
300 // Returns the number of icon mappings of |icon_type| to |page_url|. 279 // Returns the number of icon mappings of |icon_type| to |page_url|.
301 size_t NumIconMappingsForPageURL(const GURL& page_url, 280 size_t NumIconMappingsForPageURL(const GURL& page_url,
302 favicon_base::IconType icon_type) { 281 favicon_base::IconType icon_type) {
303 std::vector<IconMapping> icon_mappings; 282 std::vector<IconMapping> icon_mappings;
304 backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, icon_type, 283 backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, icon_type,
305 &icon_mappings); 284 &icon_mappings);
306 return icon_mappings.size(); 285 return icon_mappings.size();
307 } 286 }
308 287
309 // Returns the icon mappings for |page_url| sorted alphabetically by icon 288 // Returns the icon mappings for |page_url| sorted alphabetically by icon
(...skipping 28 matching lines...) Expand all
338 FaviconBitmap* favicon_bitmap) { 317 FaviconBitmap* favicon_bitmap) {
339 std::vector<FaviconBitmap> favicon_bitmaps; 318 std::vector<FaviconBitmap> favicon_bitmaps;
340 if (!backend_->thumbnail_db_->GetFaviconBitmaps(icon_id, &favicon_bitmaps)) 319 if (!backend_->thumbnail_db_->GetFaviconBitmaps(icon_id, &favicon_bitmaps))
341 return false; 320 return false;
342 if (favicon_bitmaps.size() != 1) 321 if (favicon_bitmaps.size() != 1)
343 return false; 322 return false;
344 *favicon_bitmap = favicon_bitmaps[0]; 323 *favicon_bitmap = favicon_bitmaps[0];
345 return true; 324 return true;
346 } 325 }
347 326
348 // Generates |favicon_bitmap_data| with entries for the icon_urls and sizes 327 // Creates an |edge_size|x|edge_size| bitmap of |color|.
349 // specified. The bitmap_data for entries are lowercase letters of the 328 SkBitmap CreateBitmap(SkColor color, int edge_size) {
350 // alphabet starting at 'a' for the entry at index 0. 329 SkBitmap bitmap;
351 void GenerateFaviconBitmapData( 330 bitmap.allocN32Pixels(edge_size, edge_size);
352 const GURL& icon_url1, 331 bitmap.eraseColor(color);
353 const std::vector<int>& icon_url1_sizes, 332 return bitmap;
354 std::vector<favicon_base::FaviconRawBitmapData>* favicon_bitmap_data) {
355 GenerateFaviconBitmapData(icon_url1, icon_url1_sizes, GURL(),
356 std::vector<int>(), favicon_bitmap_data);
357 }
358
359 void GenerateFaviconBitmapData(
360 const GURL& icon_url1,
361 const std::vector<int>& icon_url1_sizes,
362 const GURL& icon_url2,
363 const std::vector<int>& icon_url2_sizes,
364 std::vector<favicon_base::FaviconRawBitmapData>* favicon_bitmap_data) {
365 favicon_bitmap_data->clear();
366
367 char bitmap_char = 'a';
368 for (size_t i = 0; i < icon_url1_sizes.size(); ++i) {
369 std::vector<unsigned char> data;
370 data.push_back(bitmap_char);
371 favicon_base::FaviconRawBitmapData bitmap_data_element;
372 bitmap_data_element.bitmap_data =
373 base::RefCountedBytes::TakeVector(&data);
374 bitmap_data_element.pixel_size =
375 gfx::Size(icon_url1_sizes[i], icon_url1_sizes[i]);
376 bitmap_data_element.icon_url = icon_url1;
377 favicon_bitmap_data->push_back(bitmap_data_element);
378
379 ++bitmap_char;
380 }
381
382 for (size_t i = 0; i < icon_url2_sizes.size(); ++i) {
383 std::vector<unsigned char> data;
384 data.push_back(bitmap_char);
385 favicon_base::FaviconRawBitmapData bitmap_data_element;
386 bitmap_data_element.bitmap_data =
387 base::RefCountedBytes::TakeVector(&data);
388 bitmap_data_element.pixel_size =
389 gfx::Size(icon_url2_sizes[i], icon_url2_sizes[i]);
390 bitmap_data_element.icon_url = icon_url2;
391 favicon_bitmap_data->push_back(bitmap_data_element);
392
393 ++bitmap_char;
394 }
395 } 333 }
396 334
397 // Returns true if |bitmap_data| is equal to |expected_data|. 335 // Returns true if |bitmap_data| is equal to |expected_data|.
398 bool BitmapDataEqual(char expected_data, 336 bool BitmapDataEqual(char expected_data,
399 scoped_refptr<base::RefCountedMemory> bitmap_data) { 337 scoped_refptr<base::RefCountedMemory> bitmap_data) {
400 return bitmap_data.get() && 338 return bitmap_data.get() &&
401 bitmap_data->size() == 1u && 339 bitmap_data->size() == 1u &&
402 *bitmap_data->front() == expected_data; 340 *bitmap_data->front() == expected_data;
403 } 341 }
404 342
343 // Returns true if |bitmap_data| is of |color|.
344 bool BitmapColorEqual(SkColor expected_color,
345 scoped_refptr<base::RefCountedMemory> bitmap_data) {
346 SkBitmap bitmap;
347 if (!gfx::PNGCodec::Decode(
348 bitmap_data->front(), bitmap_data->size(), &bitmap))
349 return false;
350 SkAutoLockPixels bitmap_lock(bitmap);
351 return expected_color == bitmap.getColor(0, 0);
352 }
353
405 private: 354 private:
406 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTest); 355 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTest);
407 }; 356 };
408 357
409 class InMemoryHistoryBackendTest : public HistoryBackendTestBase { 358 class InMemoryHistoryBackendTest : public HistoryBackendTestBase {
410 public: 359 public:
411 InMemoryHistoryBackendTest() {} 360 InMemoryHistoryBackendTest() {}
412 virtual ~InMemoryHistoryBackendTest() {} 361 virtual ~InMemoryHistoryBackendTest() {}
413 362
414 protected: 363 protected:
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 url_info2.set_hidden(false); 1513 url_info2.set_hidden(false);
1565 backend_->db_->AddURL(url_info2); 1514 backend_->db_->AddURL(url_info2);
1566 1515
1567 history::RedirectList redirects; 1516 history::RedirectList redirects;
1568 redirects.push_back(url2); 1517 redirects.push_back(url2);
1569 redirects.push_back(url1); 1518 redirects.push_back(url1);
1570 backend_->recent_redirects_.Put(url1, redirects); 1519 backend_->recent_redirects_.Put(url1, redirects);
1571 1520
1572 const GURL icon_url1("http://www.google.com/icon"); 1521 const GURL icon_url1("http://www.google.com/icon");
1573 const GURL icon_url2("http://www.google.com/icon2"); 1522 const GURL icon_url2("http://www.google.com/icon2");
1523 std::vector<SkBitmap> bitmaps;
1524 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
1525 bitmaps.push_back(CreateBitmap(SK_ColorRED, kLargeEdgeSize));
1574 1526
1575 // Generate bitmap data for a page with two favicons. 1527 // Add a favicon.
1576 std::vector<favicon_base::FaviconRawBitmapData> two_favicon_bitmap_data; 1528 backend_->SetFavicons(url1, favicon_base::FAVICON, icon_url1, bitmaps);
1577 GenerateFaviconBitmapData(icon_url1, GetEdgeSizesSmallAndLarge(), 1529 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON));
1578 icon_url2, GetEdgeSizesSmallAndLarge(), &two_favicon_bitmap_data); 1530 EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, favicon_base::FAVICON));
1579
1580 // Generate bitmap data for a page with a single favicon.
1581 std::vector<favicon_base::FaviconRawBitmapData> one_favicon_bitmap_data;
1582 GenerateFaviconBitmapData(icon_url1, GetEdgeSizesSmallAndLarge(),
1583 &one_favicon_bitmap_data);
1584
1585 // Add two favicons
1586 backend_->SetFavicons(url1, favicon_base::FAVICON, two_favicon_bitmap_data);
1587 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON));
1588 EXPECT_EQ(2u, NumIconMappingsForPageURL(url2, favicon_base::FAVICON));
1589 1531
1590 // Add one touch_icon 1532 // Add one touch_icon
1591 backend_->SetFavicons( 1533 backend_->SetFavicons(url1, favicon_base::TOUCH_ICON, icon_url1, bitmaps);
1592 url1, favicon_base::TOUCH_ICON, one_favicon_bitmap_data);
1593 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON)); 1534 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON));
1594 EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, favicon_base::TOUCH_ICON)); 1535 EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, favicon_base::TOUCH_ICON));
1595 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); 1536 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON));
1596 1537
1597 // Add one TOUCH_PRECOMPOSED_ICON 1538 // Add one TOUCH_PRECOMPOSED_ICON
1598 backend_->SetFavicons( 1539 backend_->SetFavicons(
1599 url1, favicon_base::TOUCH_PRECOMPOSED_ICON, one_favicon_bitmap_data); 1540 url1, favicon_base::TOUCH_PRECOMPOSED_ICON, icon_url1, bitmaps);
1600 // The touch_icon was replaced. 1541 // The touch_icon was replaced.
1601 EXPECT_EQ(0u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON)); 1542 EXPECT_EQ(0u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON));
1602 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); 1543 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON));
1603 EXPECT_EQ( 1544 EXPECT_EQ(
1604 1u, 1545 1u,
1605 NumIconMappingsForPageURL(url1, favicon_base::TOUCH_PRECOMPOSED_ICON)); 1546 NumIconMappingsForPageURL(url1, favicon_base::TOUCH_PRECOMPOSED_ICON));
1606 EXPECT_EQ( 1547 EXPECT_EQ(
1607 1u, 1548 1u,
1608 NumIconMappingsForPageURL(url2, favicon_base::TOUCH_PRECOMPOSED_ICON)); 1549 NumIconMappingsForPageURL(url2, favicon_base::TOUCH_PRECOMPOSED_ICON));
1609 1550
1610 // Add a touch_icon. 1551 // Add a touch_icon.
1611 backend_->SetFavicons( 1552 backend_->SetFavicons(url1, favicon_base::TOUCH_ICON, icon_url1, bitmaps);
1612 url1, favicon_base::TOUCH_ICON, one_favicon_bitmap_data);
1613 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON)); 1553 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON));
1614 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); 1554 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON));
1615 // The TOUCH_PRECOMPOSED_ICON was replaced. 1555 // The TOUCH_PRECOMPOSED_ICON was replaced.
1616 EXPECT_EQ( 1556 EXPECT_EQ(
1617 0u, 1557 0u,
1618 NumIconMappingsForPageURL(url1, favicon_base::TOUCH_PRECOMPOSED_ICON)); 1558 NumIconMappingsForPageURL(url1, favicon_base::TOUCH_PRECOMPOSED_ICON));
1619 1559
1620 // Add a single favicon. 1560 // Add a different favicon.
1621 backend_->SetFavicons(url1, favicon_base::FAVICON, one_favicon_bitmap_data); 1561 backend_->SetFavicons(url1, favicon_base::FAVICON, icon_url2, bitmaps);
1622 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON)); 1562 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON));
1623 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); 1563 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON));
1624 EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, favicon_base::FAVICON)); 1564 EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, favicon_base::FAVICON));
1625
1626 // Add two favicons.
1627 backend_->SetFavicons(url1, favicon_base::FAVICON, two_favicon_bitmap_data);
1628 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON));
1629 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON));
1630 } 1565 }
1631 1566
1632 // Test that there is no churn in icon mappings from calling 1567 // Test that there is no churn in icon mappings from calling
1633 // SetFavicons() twice with the same |favicon_bitmap_data| parameter. 1568 // SetFavicons() twice with the same |bitmaps| parameter.
1634 TEST_F(HistoryBackendTest, SetFaviconMappingsForPageDuplicates) { 1569 TEST_F(HistoryBackendTest, SetFaviconMappingsForPageDuplicates) {
1635 const GURL url("http://www.google.com/"); 1570 const GURL url("http://www.google.com/");
1636 const GURL icon_url("http://www.google.com/icon"); 1571 const GURL icon_url("http://www.google.com/icon");
1637 1572
1638 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 1573 std::vector<SkBitmap> bitmaps;
1639 GenerateFaviconBitmapData(icon_url, GetEdgeSizesSmallAndLarge(), 1574 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
1640 &favicon_bitmap_data); 1575 bitmaps.push_back(CreateBitmap(SK_ColorRED, kLargeEdgeSize));
1641 1576
1642 backend_->SetFavicons(url, favicon_base::FAVICON, favicon_bitmap_data); 1577 backend_->SetFavicons(url, favicon_base::FAVICON, icon_url, bitmaps);
1643 1578
1644 std::vector<IconMapping> icon_mappings; 1579 std::vector<IconMapping> icon_mappings;
1645 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( 1580 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(
1646 url, favicon_base::FAVICON, &icon_mappings)); 1581 url, favicon_base::FAVICON, &icon_mappings));
1647 EXPECT_EQ(1u, icon_mappings.size()); 1582 EXPECT_EQ(1u, icon_mappings.size());
1648 IconMappingID mapping_id = icon_mappings[0].mapping_id; 1583 IconMappingID mapping_id = icon_mappings[0].mapping_id;
1649 1584
1650 backend_->SetFavicons(url, favicon_base::FAVICON, favicon_bitmap_data); 1585 backend_->SetFavicons(url, favicon_base::FAVICON, icon_url, bitmaps);
1651 1586
1652 icon_mappings.clear(); 1587 icon_mappings.clear();
1653 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( 1588 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(
1654 url, favicon_base::FAVICON, &icon_mappings)); 1589 url, favicon_base::FAVICON, &icon_mappings));
1655 EXPECT_EQ(1u, icon_mappings.size()); 1590 EXPECT_EQ(1u, icon_mappings.size());
1656 1591
1657 // The same row in the icon_mapping table should be used for the mapping as 1592 // The same row in the icon_mapping table should be used for the mapping as
1658 // before. 1593 // before.
1659 EXPECT_EQ(mapping_id, icon_mappings[0].mapping_id); 1594 EXPECT_EQ(mapping_id, icon_mappings[0].mapping_id);
1660 } 1595 }
1661 1596
1662 // Test that calling SetFavicons() with FaviconBitmapData of different pixel 1597 // Test that calling SetFavicons() with FaviconBitmapData of different pixel
1663 // sizes than the initially passed in FaviconBitmapData deletes the no longer 1598 // sizes than the initially passed in FaviconBitmapData deletes the no longer
1664 // used favicon bitmaps. 1599 // used favicon bitmaps.
1665 TEST_F(HistoryBackendTest, SetFaviconsDeleteBitmaps) { 1600 TEST_F(HistoryBackendTest, SetFaviconsDeleteBitmaps) {
1666 const GURL page_url("http://www.google.com/"); 1601 const GURL page_url("http://www.google.com/");
1667 const GURL icon_url("http://www.google.com/icon"); 1602 const GURL icon_url("http://www.google.com/icon");
1668 1603
1669 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 1604 std::vector<SkBitmap> bitmaps;
1670 GenerateFaviconBitmapData(icon_url, GetEdgeSizesSmallAndLarge(), 1605 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
1671 &favicon_bitmap_data); 1606 bitmaps.push_back(CreateBitmap(SK_ColorRED, kLargeEdgeSize));
1672 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); 1607 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
1673 1608
1674 // Test initial state. 1609 // Test initial state.
1675 std::vector<IconMapping> icon_mappings; 1610 std::vector<IconMapping> icon_mappings;
1676 EXPECT_TRUE(GetSortedIconMappingsForPageURL(page_url, &icon_mappings)); 1611 EXPECT_TRUE(GetSortedIconMappingsForPageURL(page_url, &icon_mappings));
1677 EXPECT_EQ(1u, icon_mappings.size()); 1612 EXPECT_EQ(1u, icon_mappings.size());
1678 EXPECT_EQ(icon_url, icon_mappings[0].icon_url); 1613 EXPECT_EQ(icon_url, icon_mappings[0].icon_url);
1679 EXPECT_EQ(favicon_base::FAVICON, icon_mappings[0].icon_type); 1614 EXPECT_EQ(favicon_base::FAVICON, icon_mappings[0].icon_type);
1680 favicon_base::FaviconID favicon_id = icon_mappings[0].icon_id; 1615 favicon_base::FaviconID favicon_id = icon_mappings[0].icon_id;
1681 1616
1682 std::vector<FaviconBitmap> favicon_bitmaps; 1617 std::vector<FaviconBitmap> favicon_bitmaps;
1683 EXPECT_TRUE(GetSortedFaviconBitmaps(favicon_id, &favicon_bitmaps)); 1618 EXPECT_TRUE(GetSortedFaviconBitmaps(favicon_id, &favicon_bitmaps));
1684 EXPECT_EQ(2u, favicon_bitmaps.size()); 1619 EXPECT_EQ(2u, favicon_bitmaps.size());
1685 FaviconBitmapID small_bitmap_id = favicon_bitmaps[0].bitmap_id; 1620 FaviconBitmapID small_bitmap_id = favicon_bitmaps[0].bitmap_id;
1686 EXPECT_NE(0, small_bitmap_id); 1621 EXPECT_NE(0, small_bitmap_id);
1687 EXPECT_TRUE(BitmapDataEqual('a', favicon_bitmaps[0].bitmap_data)); 1622 EXPECT_TRUE(BitmapColorEqual(SK_ColorBLUE, favicon_bitmaps[0].bitmap_data));
1688 EXPECT_EQ(kSmallSize, favicon_bitmaps[0].pixel_size); 1623 EXPECT_EQ(kSmallSize, favicon_bitmaps[0].pixel_size);
1689 FaviconBitmapID large_bitmap_id = favicon_bitmaps[1].bitmap_id; 1624 FaviconBitmapID large_bitmap_id = favicon_bitmaps[1].bitmap_id;
1690 EXPECT_NE(0, large_bitmap_id); 1625 EXPECT_NE(0, large_bitmap_id);
1691 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmaps[1].bitmap_data)); 1626 EXPECT_TRUE(BitmapColorEqual(SK_ColorRED, favicon_bitmaps[1].bitmap_data));
1692 EXPECT_EQ(kLargeSize, favicon_bitmaps[1].pixel_size); 1627 EXPECT_EQ(kLargeSize, favicon_bitmaps[1].pixel_size);
1693 1628
1694 // Call SetFavicons() with bitmap data for only the large bitmap. Check that 1629 // Call SetFavicons() with bitmap data for only the large bitmap. Check that
1695 // the small bitmap is in fact deleted. 1630 // the small bitmap is in fact deleted.
1696 GenerateFaviconBitmapData(icon_url, GetEdgeSizesLarge(), 1631 bitmaps.clear();
1697 &favicon_bitmap_data); 1632 bitmaps.push_back(CreateBitmap(SK_ColorWHITE, kLargeEdgeSize));
1698 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); 1633 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
1699 1634
1700 scoped_refptr<base::RefCountedMemory> bitmap_data_out; 1635 scoped_refptr<base::RefCountedMemory> bitmap_data_out;
1701 gfx::Size pixel_size_out; 1636 gfx::Size pixel_size_out;
1702 EXPECT_FALSE(backend_->thumbnail_db_->GetFaviconBitmap(small_bitmap_id, 1637 EXPECT_FALSE(backend_->thumbnail_db_->GetFaviconBitmap(small_bitmap_id,
1703 NULL, &bitmap_data_out, &pixel_size_out)); 1638 NULL, &bitmap_data_out, &pixel_size_out));
1704 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmap(large_bitmap_id, 1639 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmap(large_bitmap_id,
1705 NULL, &bitmap_data_out, &pixel_size_out)); 1640 NULL, &bitmap_data_out, &pixel_size_out));
1706 EXPECT_TRUE(BitmapDataEqual('a', bitmap_data_out)); 1641 EXPECT_TRUE(BitmapColorEqual(SK_ColorWHITE, bitmap_data_out));
1707 EXPECT_EQ(kLargeSize, pixel_size_out); 1642 EXPECT_EQ(kLargeSize, pixel_size_out);
1708 1643
1709 icon_mappings.clear(); 1644 icon_mappings.clear();
1710 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, 1645 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url,
1711 &icon_mappings)); 1646 &icon_mappings));
1712 EXPECT_EQ(1u, icon_mappings.size()); 1647 EXPECT_EQ(1u, icon_mappings.size());
1713 EXPECT_EQ(favicon_id, icon_mappings[0].icon_id); 1648 EXPECT_EQ(favicon_id, icon_mappings[0].icon_id);
1714 1649
1715 // Call SetFavicons() with no bitmap data. Check that the bitmaps and icon
1716 // mappings are deleted.
1717 favicon_bitmap_data.clear();
1718 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data);
1719
1720 EXPECT_FALSE(backend_->thumbnail_db_->GetFaviconBitmap(large_bitmap_id, NULL,
1721 NULL, NULL));
1722 icon_mappings.clear();
1723 EXPECT_FALSE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url,
1724 &icon_mappings));
1725
1726 // Notifications should have been broadcast for each call to SetFavicons(). 1650 // Notifications should have been broadcast for each call to SetFavicons().
1727 EXPECT_EQ(3, num_broadcasted_notifications()); 1651 EXPECT_EQ(2, num_broadcasted_notifications());
1728 } 1652 }
1729 1653
1730 // Test updating a single favicon bitmap's data via SetFavicons. 1654 // Test updating a single favicon bitmap's data via SetFavicons.
1731 TEST_F(HistoryBackendTest, SetFaviconsReplaceBitmapData) { 1655 TEST_F(HistoryBackendTest, SetFaviconsReplaceBitmapData) {
1732 const GURL page_url("http://www.google.com/"); 1656 const GURL page_url("http://www.google.com/");
1733 const GURL icon_url("http://www.google.com/icon"); 1657 const GURL icon_url("http://www.google.com/icon");
1734 1658 std::vector<SkBitmap> bitmaps;
1735 std::vector<unsigned char> data_initial; 1659 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
1736 data_initial.push_back('a');
1737
1738 favicon_base::FaviconRawBitmapData bitmap_data_element;
1739 bitmap_data_element.bitmap_data =
1740 base::RefCountedBytes::TakeVector(&data_initial);
1741 bitmap_data_element.pixel_size = kSmallSize;
1742 bitmap_data_element.icon_url = icon_url;
1743 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data;
1744 favicon_bitmap_data.push_back(bitmap_data_element);
1745 1660
1746 // Add bitmap to the database. 1661 // Add bitmap to the database.
1747 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); 1662 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
1748 1663
1749 favicon_base::FaviconID original_favicon_id = 1664 favicon_base::FaviconID original_favicon_id =
1750 backend_->thumbnail_db_->GetFaviconIDForFaviconURL( 1665 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(
1751 icon_url, favicon_base::FAVICON, NULL); 1666 icon_url, favicon_base::FAVICON, NULL);
1752 EXPECT_NE(0, original_favicon_id); 1667 EXPECT_NE(0, original_favicon_id);
1753 FaviconBitmap original_favicon_bitmap; 1668 FaviconBitmap original_favicon_bitmap;
1754 EXPECT_TRUE( 1669 EXPECT_TRUE(
1755 GetOnlyFaviconBitmap(original_favicon_id, &original_favicon_bitmap)); 1670 GetOnlyFaviconBitmap(original_favicon_id, &original_favicon_bitmap));
1756 EXPECT_TRUE(BitmapDataEqual('a', original_favicon_bitmap.bitmap_data)); 1671 EXPECT_TRUE(
1672 BitmapColorEqual(SK_ColorBLUE, original_favicon_bitmap.bitmap_data));
1757 1673
1758 EXPECT_EQ(1, num_broadcasted_notifications()); 1674 EXPECT_EQ(1, num_broadcasted_notifications());
1759 1675
1760 // Call SetFavicons() with completely identical data. 1676 // Call SetFavicons() with completely identical data.
1761 std::vector<unsigned char> updated_data; 1677 bitmaps[0] = CreateBitmap(SK_ColorBLUE, kSmallEdgeSize);
1762 updated_data.push_back('a'); 1678 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
1763 favicon_bitmap_data[0].bitmap_data = new base::RefCountedBytes(updated_data);
1764 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data);
1765 1679
1766 favicon_base::FaviconID updated_favicon_id = 1680 favicon_base::FaviconID updated_favicon_id =
1767 backend_->thumbnail_db_->GetFaviconIDForFaviconURL( 1681 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(
1768 icon_url, favicon_base::FAVICON, NULL); 1682 icon_url, favicon_base::FAVICON, NULL);
1769 EXPECT_NE(0, updated_favicon_id); 1683 EXPECT_NE(0, updated_favicon_id);
1770 FaviconBitmap updated_favicon_bitmap; 1684 FaviconBitmap updated_favicon_bitmap;
1771 EXPECT_TRUE( 1685 EXPECT_TRUE(
1772 GetOnlyFaviconBitmap(updated_favicon_id, &updated_favicon_bitmap)); 1686 GetOnlyFaviconBitmap(updated_favicon_id, &updated_favicon_bitmap));
1773 EXPECT_TRUE(BitmapDataEqual('a', updated_favicon_bitmap.bitmap_data)); 1687 EXPECT_TRUE(
1688 BitmapColorEqual(SK_ColorBLUE, updated_favicon_bitmap.bitmap_data));
1774 1689
1775 // Because the bitmap data is byte equivalent, no notifications should have 1690 // Because the bitmap data is byte equivalent, no notifications should have
1776 // been broadcasted. 1691 // been broadcasted.
1777 EXPECT_EQ(1, num_broadcasted_notifications()); 1692 EXPECT_EQ(1, num_broadcasted_notifications());
1778 1693
1779 // Call SetFavicons() with identical data but a different bitmap. 1694 // Call SetFavicons() with a different bitmap of the same size.
1780 updated_data[0] = 'b'; 1695 bitmaps[0] = CreateBitmap(SK_ColorWHITE, kSmallEdgeSize);
1781 favicon_bitmap_data[0].bitmap_data = new base::RefCountedBytes(updated_data); 1696 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
1782 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data);
1783 1697
1784 updated_favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( 1698 updated_favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL(
1785 icon_url, favicon_base::FAVICON, NULL); 1699 icon_url, favicon_base::FAVICON, NULL);
1786 EXPECT_NE(0, updated_favicon_id); 1700 EXPECT_NE(0, updated_favicon_id);
1787 EXPECT_TRUE( 1701 EXPECT_TRUE(
1788 GetOnlyFaviconBitmap(updated_favicon_id, &updated_favicon_bitmap)); 1702 GetOnlyFaviconBitmap(updated_favicon_id, &updated_favicon_bitmap));
1789 EXPECT_TRUE(BitmapDataEqual('b', updated_favicon_bitmap.bitmap_data)); 1703 EXPECT_TRUE(
1704 BitmapColorEqual(SK_ColorWHITE, updated_favicon_bitmap.bitmap_data));
1790 1705
1791 // There should be no churn in FaviconIDs or FaviconBitmapIds even though 1706 // There should be no churn in FaviconIDs or FaviconBitmapIds even though
1792 // the bitmap data changed. 1707 // the bitmap data changed.
1793 EXPECT_EQ(original_favicon_bitmap.icon_id, updated_favicon_bitmap.icon_id); 1708 EXPECT_EQ(original_favicon_bitmap.icon_id, updated_favicon_bitmap.icon_id);
1794 EXPECT_EQ(original_favicon_bitmap.bitmap_id, 1709 EXPECT_EQ(original_favicon_bitmap.bitmap_id,
1795 updated_favicon_bitmap.bitmap_id); 1710 updated_favicon_bitmap.bitmap_id);
1796 1711
1797 // A notification should have been broadcasted as the favicon bitmap data has 1712 // A notification should have been broadcasted as the favicon bitmap data has
1798 // changed. 1713 // changed.
1799 EXPECT_EQ(2, num_broadcasted_notifications()); 1714 EXPECT_EQ(2, num_broadcasted_notifications());
1800 } 1715 }
1801 1716
1802 // Test that if two pages share the same FaviconID, changing the favicon for 1717 // Test that if two pages share the same FaviconID, changing the favicon for
1803 // one page does not affect the other. 1718 // one page does not affect the other.
1804 TEST_F(HistoryBackendTest, SetFaviconsSameFaviconURLForTwoPages) { 1719 TEST_F(HistoryBackendTest, SetFaviconsSameFaviconURLForTwoPages) {
1805 GURL icon_url("http://www.google.com/favicon.ico"); 1720 GURL icon_url("http://www.google.com/favicon.ico");
1806 GURL icon_url_new("http://www.google.com/favicon2.ico"); 1721 GURL icon_url_new("http://www.google.com/favicon2.ico");
1807 GURL page_url1("http://www.google.com"); 1722 GURL page_url1("http://www.google.com");
1808 GURL page_url2("http://www.google.ca"); 1723 GURL page_url2("http://www.google.ca");
1724 std::vector<SkBitmap> bitmaps;
1725 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
1726 bitmaps.push_back(CreateBitmap(SK_ColorRED, kLargeEdgeSize));
1809 1727
1810 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 1728 backend_->SetFavicons(page_url1, favicon_base::FAVICON, icon_url, bitmaps);
1811 GenerateFaviconBitmapData(icon_url, GetEdgeSizesSmallAndLarge(),
1812 &favicon_bitmap_data);
1813
1814 backend_->SetFavicons(page_url1, favicon_base::FAVICON, favicon_bitmap_data);
1815 1729
1816 std::vector<GURL> icon_urls; 1730 std::vector<GURL> icon_urls;
1817 icon_urls.push_back(icon_url); 1731 icon_urls.push_back(icon_url);
1818 1732
1819 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results; 1733 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results;
1820 backend_->UpdateFaviconMappingsAndFetch(page_url2, 1734 backend_->UpdateFaviconMappingsAndFetch(page_url2,
1821 icon_urls, 1735 icon_urls,
1822 favicon_base::FAVICON, 1736 favicon_base::FAVICON,
1823 GetEdgeSizesSmallAndLarge(), 1737 GetEdgeSizesSmallAndLarge(),
1824 &bitmap_results); 1738 &bitmap_results);
1825 1739
1826 // Check that the same FaviconID is mapped to both page URLs. 1740 // Check that the same FaviconID is mapped to both page URLs.
1827 std::vector<IconMapping> icon_mappings; 1741 std::vector<IconMapping> icon_mappings;
1828 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( 1742 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(
1829 page_url1, &icon_mappings)); 1743 page_url1, &icon_mappings));
1830 EXPECT_EQ(1u, icon_mappings.size()); 1744 EXPECT_EQ(1u, icon_mappings.size());
1831 favicon_base::FaviconID favicon_id = icon_mappings[0].icon_id; 1745 favicon_base::FaviconID favicon_id = icon_mappings[0].icon_id;
1832 EXPECT_NE(0, favicon_id); 1746 EXPECT_NE(0, favicon_id);
1833 1747
1834 icon_mappings.clear(); 1748 icon_mappings.clear();
1835 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( 1749 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(
1836 page_url2, &icon_mappings)); 1750 page_url2, &icon_mappings));
1837 EXPECT_EQ(1u, icon_mappings.size()); 1751 EXPECT_EQ(1u, icon_mappings.size());
1838 EXPECT_EQ(favicon_id, icon_mappings[0].icon_id); 1752 EXPECT_EQ(favicon_id, icon_mappings[0].icon_id);
1839 1753
1840 // Change the icon URL that |page_url1| is mapped to. 1754 // Change the icon URL that |page_url1| is mapped to.
1841 GenerateFaviconBitmapData(icon_url_new, GetEdgeSizesSmall(), 1755 bitmaps.clear();
1842 &favicon_bitmap_data); 1756 bitmaps.push_back(CreateBitmap(SK_ColorWHITE, kSmallEdgeSize));
1843 backend_->SetFavicons(page_url1, favicon_base::FAVICON, favicon_bitmap_data); 1757 backend_->SetFavicons(
1758 page_url1, favicon_base::FAVICON, icon_url_new, bitmaps);
1844 1759
1845 // |page_url1| should map to a new FaviconID and have valid bitmap data. 1760 // |page_url1| should map to a new FaviconID and have valid bitmap data.
1846 icon_mappings.clear(); 1761 icon_mappings.clear();
1847 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( 1762 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(
1848 page_url1, &icon_mappings)); 1763 page_url1, &icon_mappings));
1849 EXPECT_EQ(1u, icon_mappings.size()); 1764 EXPECT_EQ(1u, icon_mappings.size());
1850 EXPECT_EQ(icon_url_new, icon_mappings[0].icon_url); 1765 EXPECT_EQ(icon_url_new, icon_mappings[0].icon_url);
1851 EXPECT_NE(favicon_id, icon_mappings[0].icon_id); 1766 EXPECT_NE(favicon_id, icon_mappings[0].icon_id);
1852 1767
1853 std::vector<FaviconBitmap> favicon_bitmaps; 1768 std::vector<FaviconBitmap> favicon_bitmaps;
(...skipping 18 matching lines...) Expand all
1872 // and each call to UpdateFaviconMappingsAndFetch(). 1787 // and each call to UpdateFaviconMappingsAndFetch().
1873 EXPECT_EQ(3, num_broadcasted_notifications()); 1788 EXPECT_EQ(3, num_broadcasted_notifications());
1874 } 1789 }
1875 1790
1876 // Test that no notifications are broadcast as a result of calling 1791 // Test that no notifications are broadcast as a result of calling
1877 // UpdateFaviconMappingsAndFetch() for an icon URL which is already 1792 // UpdateFaviconMappingsAndFetch() for an icon URL which is already
1878 // mapped to the passed in page URL. 1793 // mapped to the passed in page URL.
1879 TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchNoChange) { 1794 TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchNoChange) {
1880 GURL page_url("http://www.google.com"); 1795 GURL page_url("http://www.google.com");
1881 GURL icon_url("http://www.google.com/favicon.ico"); 1796 GURL icon_url("http://www.google.com/favicon.ico");
1882 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 1797 std::vector<SkBitmap> bitmaps;
1883 GenerateFaviconBitmapData(icon_url, GetEdgeSizesSmall(), 1798 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
1884 &favicon_bitmap_data);
1885 1799
1886 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); 1800 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
1887 1801
1888 favicon_base::FaviconID icon_id = 1802 favicon_base::FaviconID icon_id =
1889 backend_->thumbnail_db_->GetFaviconIDForFaviconURL( 1803 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(
1890 icon_url, favicon_base::FAVICON, NULL); 1804 icon_url, favicon_base::FAVICON, NULL);
1891 EXPECT_NE(0, icon_id); 1805 EXPECT_NE(0, icon_id);
1892 EXPECT_EQ(1, num_broadcasted_notifications()); 1806 EXPECT_EQ(1, num_broadcasted_notifications());
1893 1807
1894 std::vector<GURL> icon_urls; 1808 std::vector<GURL> icon_urls;
1895 icon_urls.push_back(icon_url); 1809 icon_urls.push_back(icon_url);
1896 1810
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 EXPECT_NE(base::Time(), favicon_bitmap.last_updated); 1869 EXPECT_NE(base::Time(), favicon_bitmap.last_updated);
1956 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data)); 1870 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data));
1957 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); 1871 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size);
1958 } 1872 }
1959 1873
1960 // Test calling MergeFavicon() when |page_url| is known to the database. 1874 // Test calling MergeFavicon() when |page_url| is known to the database.
1961 TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { 1875 TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) {
1962 GURL page_url("http://www.google.com"); 1876 GURL page_url("http://www.google.com");
1963 GURL icon_url1("http:/www.google.com/favicon.ico"); 1877 GURL icon_url1("http:/www.google.com/favicon.ico");
1964 GURL icon_url2("http://www.google.com/favicon2.ico"); 1878 GURL icon_url2("http://www.google.com/favicon2.ico");
1879 std::vector<SkBitmap> bitmaps;
1880 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
1965 1881
1966 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 1882 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url1, bitmaps);
1967 GenerateFaviconBitmapData(icon_url1, GetEdgeSizesSmall(),
1968 &favicon_bitmap_data);
1969
1970 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data);
1971 1883
1972 // Test initial state. 1884 // Test initial state.
1973 std::vector<IconMapping> icon_mappings; 1885 std::vector<IconMapping> icon_mappings;
1974 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, 1886 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url,
1975 &icon_mappings)); 1887 &icon_mappings));
1976 EXPECT_EQ(1u, icon_mappings.size()); 1888 EXPECT_EQ(1u, icon_mappings.size());
1977 EXPECT_EQ(icon_url1, icon_mappings[0].icon_url); 1889 EXPECT_EQ(icon_url1, icon_mappings[0].icon_url);
1978 1890
1979 FaviconBitmap favicon_bitmap; 1891 FaviconBitmap favicon_bitmap;
1980 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap)); 1892 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap));
1981 EXPECT_NE(base::Time(), favicon_bitmap.last_updated); 1893 EXPECT_NE(base::Time(), favicon_bitmap.last_updated);
1982 EXPECT_TRUE(BitmapDataEqual('a', favicon_bitmap.bitmap_data)); 1894 EXPECT_TRUE(BitmapColorEqual(SK_ColorBLUE, favicon_bitmap.bitmap_data));
1983 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); 1895 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size);
1984 1896
1985 EXPECT_EQ(1, num_broadcasted_notifications()); 1897 EXPECT_EQ(1, num_broadcasted_notifications());
1986 1898
1987 // 1) Merge identical favicon bitmap. 1899 // 1) Merge identical favicon bitmap.
1988 std::vector<unsigned char> data; 1900 std::vector<unsigned char> data;
1989 data.push_back('a'); 1901 gfx::PNGCodec::EncodeBGRASkBitmap(bitmaps[0], false, &data);
1990 scoped_refptr<base::RefCountedBytes> bitmap_data( 1902 scoped_refptr<base::RefCountedBytes> bitmap_data(
1991 new base::RefCountedBytes(data)); 1903 new base::RefCountedBytes(data));
1992 backend_->MergeFavicon( 1904 backend_->MergeFavicon(
1993 page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kSmallSize); 1905 page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kSmallSize);
1994 1906
1995 // All the data should stay the same and no notifications should have been 1907 // All the data should stay the same and no notifications should have been
1996 // sent. 1908 // sent.
1997 icon_mappings.clear(); 1909 icon_mappings.clear();
1998 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, 1910 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url,
1999 &icon_mappings)); 1911 &icon_mappings));
2000 EXPECT_EQ(1u, icon_mappings.size()); 1912 EXPECT_EQ(1u, icon_mappings.size());
2001 EXPECT_EQ(icon_url1, icon_mappings[0].icon_url); 1913 EXPECT_EQ(icon_url1, icon_mappings[0].icon_url);
2002 1914
2003 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap)); 1915 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap));
2004 EXPECT_NE(base::Time(), favicon_bitmap.last_updated); 1916 EXPECT_NE(base::Time(), favicon_bitmap.last_updated);
2005 EXPECT_TRUE(BitmapDataEqual('a', favicon_bitmap.bitmap_data)); 1917 EXPECT_TRUE(BitmapColorEqual(SK_ColorBLUE, favicon_bitmap.bitmap_data));
2006 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); 1918 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size);
2007 1919
2008 EXPECT_EQ(1, num_broadcasted_notifications()); 1920 EXPECT_EQ(1, num_broadcasted_notifications());
2009 1921
2010 // 2) Merge favicon bitmap of the same size. 1922 // 2) Merge favicon bitmap of the same size.
2011 data[0] = 'b'; 1923 data.clear();
1924 data.push_back('b');
2012 bitmap_data = new base::RefCountedBytes(data); 1925 bitmap_data = new base::RefCountedBytes(data);
2013 backend_->MergeFavicon( 1926 backend_->MergeFavicon(
2014 page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kSmallSize); 1927 page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kSmallSize);
2015 1928
2016 // The small favicon bitmap at |icon_url1| should be overwritten. 1929 // The small favicon bitmap at |icon_url1| should be overwritten.
2017 icon_mappings.clear(); 1930 icon_mappings.clear();
2018 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, 1931 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url,
2019 &icon_mappings)); 1932 &icon_mappings));
2020 EXPECT_EQ(1u, icon_mappings.size()); 1933 EXPECT_EQ(1u, icon_mappings.size());
2021 EXPECT_EQ(icon_url1, icon_mappings[0].icon_url); 1934 EXPECT_EQ(icon_url1, icon_mappings[0].icon_url);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 EXPECT_EQ(4, num_broadcasted_notifications()); 1995 EXPECT_EQ(4, num_broadcasted_notifications());
2083 } 1996 }
2084 1997
2085 // Test calling MergeFavicon() when |icon_url| is known to the database but not 1998 // Test calling MergeFavicon() when |icon_url| is known to the database but not
2086 // mapped to |page_url|. 1999 // mapped to |page_url|.
2087 TEST_F(HistoryBackendTest, MergeFaviconIconURLMappedToDifferentPageURL) { 2000 TEST_F(HistoryBackendTest, MergeFaviconIconURLMappedToDifferentPageURL) {
2088 GURL page_url1("http://www.google.com"); 2001 GURL page_url1("http://www.google.com");
2089 GURL page_url2("http://news.google.com"); 2002 GURL page_url2("http://news.google.com");
2090 GURL page_url3("http://maps.google.com"); 2003 GURL page_url3("http://maps.google.com");
2091 GURL icon_url("http:/www.google.com/favicon.ico"); 2004 GURL icon_url("http:/www.google.com/favicon.ico");
2005 std::vector<SkBitmap> bitmaps;
2006 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
2092 2007
2093 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 2008 backend_->SetFavicons(page_url1, favicon_base::FAVICON, icon_url, bitmaps);
2094 GenerateFaviconBitmapData(icon_url, GetEdgeSizesSmall(),
2095 &favicon_bitmap_data);
2096
2097 backend_->SetFavicons(page_url1, favicon_base::FAVICON, favicon_bitmap_data);
2098 2009
2099 // Test initial state. 2010 // Test initial state.
2100 std::vector<IconMapping> icon_mappings; 2011 std::vector<IconMapping> icon_mappings;
2101 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url1, 2012 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url1,
2102 &icon_mappings)); 2013 &icon_mappings));
2103 EXPECT_EQ(1u, icon_mappings.size()); 2014 EXPECT_EQ(1u, icon_mappings.size());
2104 EXPECT_EQ(icon_url, icon_mappings[0].icon_url); 2015 EXPECT_EQ(icon_url, icon_mappings[0].icon_url);
2105 2016
2106 FaviconBitmap favicon_bitmap; 2017 FaviconBitmap favicon_bitmap;
2107 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap)); 2018 EXPECT_TRUE(GetOnlyFaviconBitmap(icon_mappings[0].icon_id, &favicon_bitmap));
2108 EXPECT_NE(base::Time(), favicon_bitmap.last_updated); 2019 EXPECT_NE(base::Time(), favicon_bitmap.last_updated);
2109 EXPECT_TRUE(BitmapDataEqual('a', favicon_bitmap.bitmap_data)); 2020 EXPECT_TRUE(BitmapColorEqual(SK_ColorBLUE, favicon_bitmap.bitmap_data));
2110 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); 2021 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size);
2111 2022
2112 // 1) Merge in an identical favicon bitmap data but for a different page URL. 2023 // 1) Merge in an identical favicon bitmap data but for a different page URL.
2113 std::vector<unsigned char> data; 2024 std::vector<unsigned char> data;
2114 data.push_back('a'); 2025 gfx::PNGCodec::EncodeBGRASkBitmap(bitmaps[0], false, &data);
2115 scoped_refptr<base::RefCountedBytes> bitmap_data( 2026 scoped_refptr<base::RefCountedBytes> bitmap_data(
2116 new base::RefCountedBytes(data)); 2027 new base::RefCountedBytes(data));
2117 2028
2118 backend_->MergeFavicon( 2029 backend_->MergeFavicon(
2119 page_url2, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize); 2030 page_url2, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize);
2120 2031
2121 favicon_base::FaviconID favicon_id = 2032 favicon_base::FaviconID favicon_id =
2122 backend_->thumbnail_db_->GetFaviconIDForFaviconURL( 2033 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(
2123 icon_url, favicon_base::FAVICON, NULL); 2034 icon_url, favicon_base::FAVICON, NULL);
2124 EXPECT_NE(0, favicon_id); 2035 EXPECT_NE(0, favicon_id);
2125 2036
2126 EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap)); 2037 EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap));
2127 EXPECT_NE(base::Time(), favicon_bitmap.last_updated); 2038 EXPECT_NE(base::Time(), favicon_bitmap.last_updated);
2128 EXPECT_TRUE(BitmapDataEqual('a', favicon_bitmap.bitmap_data)); 2039 EXPECT_TRUE(BitmapColorEqual(SK_ColorBLUE, favicon_bitmap.bitmap_data));
2129 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size); 2040 EXPECT_EQ(kSmallSize, favicon_bitmap.pixel_size);
2130 2041
2131 // 2) Merging a favicon bitmap with different bitmap data for the same icon 2042 // 2) Merging a favicon bitmap with different bitmap data for the same icon
2132 // URL should overwrite the small favicon bitmap at |icon_url|. 2043 // URL should overwrite the small favicon bitmap at |icon_url|.
2133 bitmap_data->data()[0] = 'b'; 2044 data.clear();
2045 data.push_back('b');
2046 bitmap_data = new base::RefCountedBytes(data);
2134 backend_->MergeFavicon( 2047 backend_->MergeFavicon(
2135 page_url3, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize); 2048 page_url3, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize);
2136 2049
2137 favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( 2050 favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL(
2138 icon_url, favicon_base::FAVICON, NULL); 2051 icon_url, favicon_base::FAVICON, NULL);
2139 EXPECT_NE(0, favicon_id); 2052 EXPECT_NE(0, favicon_id);
2140 2053
2141 EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap)); 2054 EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap));
2142 EXPECT_NE(base::Time(), favicon_bitmap.last_updated); 2055 EXPECT_NE(base::Time(), favicon_bitmap.last_updated);
2143 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data)); 2056 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 icon_mappings[0].icon_id, &favicon_bitmaps)); 2116 icon_mappings[0].icon_id, &favicon_bitmaps));
2204 EXPECT_EQ(kMaxFaviconBitmapsPerIconURL, favicon_bitmaps.size()); 2117 EXPECT_EQ(kMaxFaviconBitmapsPerIconURL, favicon_bitmaps.size());
2205 } 2118 }
2206 2119
2207 // Tests that the favicon set by MergeFavicon() shows up in the result of 2120 // Tests that the favicon set by MergeFavicon() shows up in the result of
2208 // GetFaviconsForURL(). 2121 // GetFaviconsForURL().
2209 TEST_F(HistoryBackendTest, MergeFaviconShowsUpInGetFaviconsForURLResult) { 2122 TEST_F(HistoryBackendTest, MergeFaviconShowsUpInGetFaviconsForURLResult) {
2210 GURL page_url("http://www.google.com"); 2123 GURL page_url("http://www.google.com");
2211 GURL icon_url("http://www.google.com/favicon.ico"); 2124 GURL icon_url("http://www.google.com/favicon.ico");
2212 GURL merged_icon_url("http://wwww.google.com/favicon2.ico"); 2125 GURL merged_icon_url("http://wwww.google.com/favicon2.ico");
2213 2126 std::vector<SkBitmap> bitmaps;
2214 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 2127 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
2215 GenerateFaviconBitmapData(icon_url, GetEdgeSizesSmallAndLarge(), 2128 bitmaps.push_back(CreateBitmap(SK_ColorRED, kLargeEdgeSize));
2216 &favicon_bitmap_data);
2217 2129
2218 // Set some preexisting favicons for |page_url|. 2130 // Set some preexisting favicons for |page_url|.
2219 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); 2131 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
2220 2132
2221 // Merge small favicon. 2133 // Merge small favicon.
2222 std::vector<unsigned char> data; 2134 std::vector<unsigned char> data;
2223 data.push_back('c'); 2135 data.push_back('c');
2224 scoped_refptr<base::RefCountedBytes> bitmap_data( 2136 scoped_refptr<base::RefCountedBytes> bitmap_data(
2225 new base::RefCountedBytes(data)); 2137 new base::RefCountedBytes(data));
2226 backend_->MergeFavicon(page_url, 2138 backend_->MergeFavicon(page_url,
2227 merged_icon_url, 2139 merged_icon_url,
2228 favicon_base::FAVICON, 2140 favicon_base::FAVICON,
2229 bitmap_data, 2141 bitmap_data,
(...skipping 14 matching lines...) Expand all
2244 : bitmap_results[1]; 2156 : bitmap_results[1];
2245 EXPECT_TRUE(BitmapDataEqual('c', result.bitmap_data)); 2157 EXPECT_TRUE(BitmapDataEqual('c', result.bitmap_data));
2246 } 2158 }
2247 2159
2248 // Tests GetFaviconsForURL with icon_types priority, 2160 // Tests GetFaviconsForURL with icon_types priority,
2249 TEST_F(HistoryBackendTest, TestGetFaviconsForURLWithIconTypesPriority) { 2161 TEST_F(HistoryBackendTest, TestGetFaviconsForURLWithIconTypesPriority) {
2250 GURL page_url("http://www.google.com"); 2162 GURL page_url("http://www.google.com");
2251 GURL icon_url("http://www.google.com/favicon.ico"); 2163 GURL icon_url("http://www.google.com/favicon.ico");
2252 GURL touch_icon_url("http://wwww.google.com/touch_icon.ico"); 2164 GURL touch_icon_url("http://wwww.google.com/touch_icon.ico");
2253 2165
2254 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 2166 std::vector<SkBitmap> favicon_bitmaps;
2255 std::vector<int> favicon_size; 2167 favicon_bitmaps.push_back(CreateBitmap(SK_ColorBLUE, 16));
2256 favicon_size.push_back(16); 2168 favicon_bitmaps.push_back(CreateBitmap(SK_ColorRED, 32));
2257 favicon_size.push_back(32);
2258 GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data);
2259 ASSERT_EQ(2u, favicon_bitmap_data.size());
2260 2169
2261 std::vector<favicon_base::FaviconRawBitmapData> touch_icon_bitmap_data; 2170 std::vector<SkBitmap> touch_bitmaps;
2262 std::vector<int> touch_icon_size; 2171 touch_bitmaps.push_back(CreateBitmap(SK_ColorWHITE, 64));
2263 touch_icon_size.push_back(64);
2264 GenerateFaviconBitmapData(icon_url, touch_icon_size, &touch_icon_bitmap_data);
2265 ASSERT_EQ(1u, touch_icon_bitmap_data.size());
2266 2172
2267 // Set some preexisting favicons for |page_url|. 2173 // Set some preexisting favicons for |page_url|.
2268 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data);
2269 backend_->SetFavicons( 2174 backend_->SetFavicons(
2270 page_url, favicon_base::TOUCH_ICON, touch_icon_bitmap_data); 2175 page_url, favicon_base::FAVICON, icon_url, favicon_bitmaps);
2176 backend_->SetFavicons(
2177 page_url, favicon_base::TOUCH_ICON, touch_icon_url, touch_bitmaps);
2271 2178
2272 favicon_base::FaviconRawBitmapResult result; 2179 favicon_base::FaviconRawBitmapResult result;
2273 std::vector<int> icon_types; 2180 std::vector<int> icon_types;
2274 icon_types.push_back(favicon_base::FAVICON); 2181 icon_types.push_back(favicon_base::FAVICON);
2275 icon_types.push_back(favicon_base::TOUCH_ICON); 2182 icon_types.push_back(favicon_base::TOUCH_ICON);
2276 2183
2277 backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result); 2184 backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result);
2278 2185
2279 // Verify the result icon is 32x32 favicon. 2186 // Verify the result icon is 32x32 favicon.
2280 EXPECT_EQ(gfx::Size(32, 32), result.pixel_size); 2187 EXPECT_EQ(gfx::Size(32, 32), result.pixel_size);
2281 EXPECT_EQ(favicon_base::FAVICON, result.icon_type); 2188 EXPECT_EQ(favicon_base::FAVICON, result.icon_type);
2282 2189
2283 // Change Minimal size to 32x32 and verify the 64x64 touch icon returned. 2190 // Change Minimal size to 32x32 and verify the 64x64 touch icon returned.
2284 backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result); 2191 backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result);
2285 EXPECT_EQ(gfx::Size(64, 64), result.pixel_size); 2192 EXPECT_EQ(gfx::Size(64, 64), result.pixel_size);
2286 EXPECT_EQ(favicon_base::TOUCH_ICON, result.icon_type); 2193 EXPECT_EQ(favicon_base::TOUCH_ICON, result.icon_type);
2287 } 2194 }
2288 2195
2289 // Test the the first types of icon is returned if its size equal to the 2196 // Test the the first types of icon is returned if its size equal to the
2290 // second types icon. 2197 // second types icon.
2291 TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFavicon) { 2198 TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFavicon) {
2292 GURL page_url("http://www.google.com"); 2199 GURL page_url("http://www.google.com");
2293 GURL icon_url("http://www.google.com/favicon.ico"); 2200 GURL icon_url("http://www.google.com/favicon.ico");
2294 GURL touch_icon_url("http://wwww.google.com/touch_icon.ico"); 2201 GURL touch_icon_url("http://wwww.google.com/touch_icon.ico");
2295 2202
2296 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 2203 std::vector<SkBitmap> favicon_bitmaps;
2297 std::vector<int> favicon_size; 2204 favicon_bitmaps.push_back(CreateBitmap(SK_ColorBLUE, 16));
2298 favicon_size.push_back(16); 2205 favicon_bitmaps.push_back(CreateBitmap(SK_ColorRED, 32));
2299 favicon_size.push_back(32);
2300 GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data);
2301 ASSERT_EQ(2u, favicon_bitmap_data.size());
2302 2206
2303 std::vector<favicon_base::FaviconRawBitmapData> touch_icon_bitmap_data; 2207 std::vector<SkBitmap> touch_bitmaps;
2304 std::vector<int> touch_icon_size; 2208 touch_bitmaps.push_back(CreateBitmap(SK_ColorWHITE, 32));
2305 touch_icon_size.push_back(32);
2306 GenerateFaviconBitmapData(icon_url, touch_icon_size, &touch_icon_bitmap_data);
2307 ASSERT_EQ(1u, touch_icon_bitmap_data.size());
2308 2209
2309 // Set some preexisting favicons for |page_url|. 2210 // Set some preexisting favicons for |page_url|.
2310 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data);
2311 backend_->SetFavicons( 2211 backend_->SetFavicons(
2312 page_url, favicon_base::TOUCH_ICON, touch_icon_bitmap_data); 2212 page_url, favicon_base::FAVICON, icon_url, favicon_bitmaps);
2213 backend_->SetFavicons(
2214 page_url, favicon_base::TOUCH_ICON, touch_icon_url, touch_bitmaps);
2313 2215
2314 favicon_base::FaviconRawBitmapResult result; 2216 favicon_base::FaviconRawBitmapResult result;
2315 std::vector<int> icon_types; 2217 std::vector<int> icon_types;
2316 icon_types.push_back(favicon_base::FAVICON); 2218 icon_types.push_back(favicon_base::FAVICON);
2317 icon_types.push_back(favicon_base::TOUCH_ICON); 2219 icon_types.push_back(favicon_base::TOUCH_ICON);
2318 2220
2319 backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result); 2221 backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result);
2320 2222
2321 // Verify the result icon is 32x32 favicon. 2223 // Verify the result icon is 32x32 favicon.
2322 EXPECT_EQ(gfx::Size(32, 32), result.pixel_size); 2224 EXPECT_EQ(gfx::Size(32, 32), result.pixel_size);
2323 EXPECT_EQ(favicon_base::FAVICON, result.icon_type); 2225 EXPECT_EQ(favicon_base::FAVICON, result.icon_type);
2324 2226
2325 // Change minimal size to 32x32 and verify the 32x32 favicon returned. 2227 // Change minimal size to 32x32 and verify the 32x32 favicon returned.
2326 favicon_base::FaviconRawBitmapResult result1; 2228 favicon_base::FaviconRawBitmapResult result1;
2327 backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result1); 2229 backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result1);
2328 EXPECT_EQ(gfx::Size(32, 32), result1.pixel_size); 2230 EXPECT_EQ(gfx::Size(32, 32), result1.pixel_size);
2329 EXPECT_EQ(favicon_base::FAVICON, result1.icon_type); 2231 EXPECT_EQ(favicon_base::FAVICON, result1.icon_type);
2330 } 2232 }
2331 2233
2332 // Test the favicon is returned if its size is smaller than minimal size, 2234 // Test the favicon is returned if its size is smaller than minimal size,
2333 // because it is only one available. 2235 // because it is only one available.
2334 TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFaviconEvenItSmaller) { 2236 TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFaviconEvenItSmaller) {
2335 GURL page_url("http://www.google.com"); 2237 GURL page_url("http://www.google.com");
2336 GURL icon_url("http://www.google.com/favicon.ico"); 2238 GURL icon_url("http://www.google.com/favicon.ico");
2337 2239
2338 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 2240 std::vector<SkBitmap> bitmaps;
2339 std::vector<int> favicon_size; 2241 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, 16));
2340 favicon_size.push_back(16);
2341 GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data);
2342 ASSERT_EQ(1u, favicon_bitmap_data.size());
2343 2242
2344 // Set preexisting favicons for |page_url|. 2243 // Set preexisting favicons for |page_url|.
2345 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); 2244 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
2346 2245
2347 favicon_base::FaviconRawBitmapResult result; 2246 favicon_base::FaviconRawBitmapResult result;
2348 std::vector<int> icon_types; 2247 std::vector<int> icon_types;
2349 icon_types.push_back(favicon_base::FAVICON); 2248 icon_types.push_back(favicon_base::FAVICON);
2350 icon_types.push_back(favicon_base::TOUCH_ICON); 2249 icon_types.push_back(favicon_base::TOUCH_ICON);
2351 2250
2352 backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result); 2251 backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result);
2353 2252
2354 // Verify 16x16 icon is returned, even it small than minimal_size. 2253 // Verify 16x16 icon is returned, even it small than minimal_size.
2355 EXPECT_EQ(gfx::Size(16, 16), result.pixel_size); 2254 EXPECT_EQ(gfx::Size(16, 16), result.pixel_size);
2356 EXPECT_EQ(favicon_base::FAVICON, result.icon_type); 2255 EXPECT_EQ(favicon_base::FAVICON, result.icon_type);
2357 } 2256 }
2358 2257
2359 // Test UpdateFaviconMapingsAndFetch() when multiple icon types are passed in. 2258 // Test UpdateFaviconMapingsAndFetch() when multiple icon types are passed in.
2360 TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) { 2259 TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) {
2361 GURL page_url1("http://www.google.com"); 2260 GURL page_url1("http://www.google.com");
2362 GURL page_url2("http://news.google.com"); 2261 GURL page_url2("http://news.google.com");
2363 GURL page_url3("http://mail.google.com"); 2262 GURL page_url3("http://mail.google.com");
2364 GURL icon_urla("http://www.google.com/favicon1.ico"); 2263 GURL icon_urla("http://www.google.com/favicon1.ico");
2365 GURL icon_urlb("http://www.google.com/favicon2.ico"); 2264 GURL icon_urlb("http://www.google.com/favicon2.ico");
2366 GURL icon_urlc("http://www.google.com/favicon3.ico"); 2265 std::vector<SkBitmap> bitmaps;
2266 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
2367 2267
2368 // |page_url1| is mapped to |icon_urla| which if of type TOUCH_ICON. 2268 // |page_url1| is mapped to |icon_urla| which if of type TOUCH_ICON.
2369 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data;
2370 GenerateFaviconBitmapData(icon_urla, GetEdgeSizesSmall(),
2371 &favicon_bitmap_data);
2372 backend_->SetFavicons( 2269 backend_->SetFavicons(
2373 page_url1, favicon_base::TOUCH_ICON, favicon_bitmap_data); 2270 page_url1, favicon_base::TOUCH_ICON, icon_urla, bitmaps);
2374 2271
2375 // |page_url2| is mapped to |icon_urlb| and |icon_urlc| which are of type 2272 // |page_url2| is mapped to |icon_urlb| which is of type
2376 // TOUCH_PRECOMPOSED_ICON. 2273 // TOUCH_PRECOMPOSED_ICON.
2377 GenerateFaviconBitmapData(icon_urlb, GetEdgeSizesSmall(), icon_urlc,
2378 GetEdgeSizesSmall(), &favicon_bitmap_data);
2379 backend_->SetFavicons( 2274 backend_->SetFavicons(
2380 page_url2, favicon_base::TOUCH_PRECOMPOSED_ICON, favicon_bitmap_data); 2275 page_url2, favicon_base::TOUCH_PRECOMPOSED_ICON, icon_urlb, bitmaps);
2381 2276
2382 std::vector<GURL> icon_urls; 2277 std::vector<GURL> icon_urls;
2383 icon_urls.push_back(icon_urla); 2278 icon_urls.push_back(icon_urla);
2384 icon_urls.push_back(icon_urlb); 2279 icon_urls.push_back(icon_urlb);
2385 icon_urls.push_back(icon_urlc);
2386 2280
2387 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results; 2281 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results;
2388 backend_->UpdateFaviconMappingsAndFetch( 2282 backend_->UpdateFaviconMappingsAndFetch(
2389 page_url3, 2283 page_url3,
2390 icon_urls, 2284 icon_urls,
2391 (favicon_base::TOUCH_ICON | favicon_base::TOUCH_PRECOMPOSED_ICON), 2285 (favicon_base::TOUCH_ICON | favicon_base::TOUCH_PRECOMPOSED_ICON),
2392 GetEdgeSizesSmallAndLarge(), 2286 GetEdgeSizesSmallAndLarge(),
2393 &bitmap_results); 2287 &bitmap_results);
2394 2288
2395 // |page_url1| and |page_url2| should still be mapped to the same icon URLs. 2289 // |page_url1| and |page_url2| should still be mapped to the same icon URLs.
2396 std::vector<IconMapping> icon_mappings; 2290 std::vector<IconMapping> icon_mappings;
2397 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url1, 2291 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url1,
2398 &icon_mappings)); 2292 &icon_mappings));
2399 EXPECT_EQ(1u, icon_mappings.size()); 2293 EXPECT_EQ(1u, icon_mappings.size());
2400 EXPECT_EQ(icon_urla, icon_mappings[0].icon_url); 2294 EXPECT_EQ(icon_urla, icon_mappings[0].icon_url);
2401 EXPECT_EQ(favicon_base::TOUCH_ICON, icon_mappings[0].icon_type); 2295 EXPECT_EQ(favicon_base::TOUCH_ICON, icon_mappings[0].icon_type);
2402 2296
2403 icon_mappings.clear(); 2297 icon_mappings.clear();
2404 EXPECT_TRUE(GetSortedIconMappingsForPageURL(page_url2, &icon_mappings)); 2298 EXPECT_TRUE(GetSortedIconMappingsForPageURL(page_url2, &icon_mappings));
2405 EXPECT_EQ(2u, icon_mappings.size()); 2299 EXPECT_EQ(1u, icon_mappings.size());
2406 EXPECT_EQ(icon_urlb, icon_mappings[0].icon_url); 2300 EXPECT_EQ(icon_urlb, icon_mappings[0].icon_url);
2407 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); 2301 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type);
2408 EXPECT_EQ(icon_urlc, icon_mappings[1].icon_url);
2409 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[1].icon_type);
2410 2302
2411 // |page_url3| should be mapped only to |icon_urlb| and |icon_urlc| as 2303 // |page_url3| should be mapped only to |icon_urlb| as TOUCH_PRECOMPOSED_ICON
2412 // TOUCH_PRECOMPOSED_ICON is the largest IconType. 2304 // is the largest IconType.
2413 icon_mappings.clear(); 2305 icon_mappings.clear();
2414 EXPECT_TRUE(GetSortedIconMappingsForPageURL(page_url3, &icon_mappings)); 2306 EXPECT_TRUE(GetSortedIconMappingsForPageURL(page_url3, &icon_mappings));
2415 EXPECT_EQ(2u, icon_mappings.size()); 2307 EXPECT_EQ(1u, icon_mappings.size());
2416 EXPECT_EQ(icon_urlb, icon_mappings[0].icon_url); 2308 EXPECT_EQ(icon_urlb, icon_mappings[0].icon_url);
2417 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); 2309 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type);
2418 EXPECT_EQ(icon_urlc, icon_mappings[1].icon_url);
2419 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[1].icon_type);
2420 } 2310 }
2421 2311
2422 // Test the results of GetFaviconsFromDB() when there are no found 2312 // Test the results of GetFaviconsFromDB() when there are no found favicons.
2423 // favicons.
2424 TEST_F(HistoryBackendTest, GetFaviconsFromDBEmpty) { 2313 TEST_F(HistoryBackendTest, GetFaviconsFromDBEmpty) {
2425 const GURL page_url("http://www.google.com/"); 2314 const GURL page_url("http://www.google.com/");
2426 2315
2427 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results; 2316 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results;
2428 EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, 2317 EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url,
2429 favicon_base::FAVICON, 2318 favicon_base::FAVICON,
2430 GetEdgeSizesSmallAndLarge(), 2319 GetEdgeSizesSmallAndLarge(),
2431 &bitmap_results)); 2320 &bitmap_results));
2432 EXPECT_TRUE(bitmap_results.empty()); 2321 EXPECT_TRUE(bitmap_results.empty());
2433 } 2322 }
(...skipping 15 matching lines...) Expand all
2449 GetEdgeSizesSmallAndLarge(), 2338 GetEdgeSizesSmallAndLarge(),
2450 &bitmap_results_out)); 2339 &bitmap_results_out));
2451 EXPECT_TRUE(bitmap_results_out.empty()); 2340 EXPECT_TRUE(bitmap_results_out.empty());
2452 } 2341 }
2453 2342
2454 // Test that GetFaviconsFromDB() returns results for the bitmaps which most 2343 // Test that GetFaviconsFromDB() returns results for the bitmaps which most
2455 // closely match the passed in the desired pixel sizes. 2344 // closely match the passed in the desired pixel sizes.
2456 TEST_F(HistoryBackendTest, GetFaviconsFromDBSelectClosestMatch) { 2345 TEST_F(HistoryBackendTest, GetFaviconsFromDBSelectClosestMatch) {
2457 const GURL page_url("http://www.google.com/"); 2346 const GURL page_url("http://www.google.com/");
2458 const GURL icon_url("http://www.google.com/icon1"); 2347 const GURL icon_url("http://www.google.com/icon1");
2348 std::vector<SkBitmap> bitmaps;
2349 bitmaps.push_back(CreateBitmap(SK_ColorWHITE, kTinyEdgeSize));
2350 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
2351 bitmaps.push_back(CreateBitmap(SK_ColorRED, kLargeEdgeSize));
2459 2352
2460 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 2353 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
2461 GenerateFaviconBitmapData(icon_url, GetEdgeSizesTinySmallAndLarge(),
2462 &favicon_bitmap_data);
2463
2464 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data);
2465 2354
2466 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out; 2355 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out;
2467 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, 2356 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url,
2468 favicon_base::FAVICON, 2357 favicon_base::FAVICON,
2469 GetEdgeSizesSmallAndLarge(), 2358 GetEdgeSizesSmallAndLarge(),
2470 &bitmap_results_out)); 2359 &bitmap_results_out));
2471 2360
2472 // The bitmap data for the small and large bitmaps should be returned as their 2361 // The bitmap data for the small and large bitmaps should be returned as their
2473 // sizes match exactly. 2362 // sizes match exactly.
2474 EXPECT_EQ(2u, bitmap_results_out.size()); 2363 EXPECT_EQ(2u, bitmap_results_out.size());
2475 // No required order for results. 2364 // No required order for results.
2476 if (bitmap_results_out[0].pixel_size == kLargeSize) { 2365 if (bitmap_results_out[0].pixel_size == kLargeSize) {
2477 favicon_base::FaviconRawBitmapResult tmp_result = bitmap_results_out[0]; 2366 favicon_base::FaviconRawBitmapResult tmp_result = bitmap_results_out[0];
2478 bitmap_results_out[0] = bitmap_results_out[1]; 2367 bitmap_results_out[0] = bitmap_results_out[1];
2479 bitmap_results_out[1] = tmp_result; 2368 bitmap_results_out[1] = tmp_result;
2480 } 2369 }
2481 2370
2482 EXPECT_FALSE(bitmap_results_out[0].expired); 2371 EXPECT_FALSE(bitmap_results_out[0].expired);
2483 EXPECT_TRUE(BitmapDataEqual('b', bitmap_results_out[0].bitmap_data)); 2372 EXPECT_TRUE(
2373 BitmapColorEqual(SK_ColorBLUE, bitmap_results_out[0].bitmap_data));
2484 EXPECT_EQ(kSmallSize, bitmap_results_out[0].pixel_size); 2374 EXPECT_EQ(kSmallSize, bitmap_results_out[0].pixel_size);
2485 EXPECT_EQ(icon_url, bitmap_results_out[0].icon_url); 2375 EXPECT_EQ(icon_url, bitmap_results_out[0].icon_url);
2486 EXPECT_EQ(favicon_base::FAVICON, bitmap_results_out[0].icon_type); 2376 EXPECT_EQ(favicon_base::FAVICON, bitmap_results_out[0].icon_type);
2487 2377
2488 EXPECT_FALSE(bitmap_results_out[1].expired); 2378 EXPECT_FALSE(bitmap_results_out[1].expired);
2489 EXPECT_TRUE(BitmapDataEqual('c', bitmap_results_out[1].bitmap_data)); 2379 EXPECT_TRUE(BitmapColorEqual(SK_ColorRED, bitmap_results_out[1].bitmap_data));
2490 EXPECT_EQ(kLargeSize, bitmap_results_out[1].pixel_size); 2380 EXPECT_EQ(kLargeSize, bitmap_results_out[1].pixel_size);
2491 EXPECT_EQ(icon_url, bitmap_results_out[1].icon_url); 2381 EXPECT_EQ(icon_url, bitmap_results_out[1].icon_url);
2492 EXPECT_EQ(favicon_base::FAVICON, bitmap_results_out[1].icon_type); 2382 EXPECT_EQ(favicon_base::FAVICON, bitmap_results_out[1].icon_type);
2493 } 2383 }
2494 2384
2495 // Test that GetFaviconsFromDB() returns results from the icon URL whose
2496 // bitmaps most closely match the passed in desired sizes.
2497 TEST_F(HistoryBackendTest, GetFaviconsFromDBSingleIconURL) {
2498 const GURL page_url("http://www.google.com/");
2499
2500 const GURL icon_url1("http://www.google.com/icon1");
2501 const GURL icon_url2("http://www.google.com/icon2");
2502
2503 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data;
2504 GenerateFaviconBitmapData(icon_url1, GetEdgeSizesSmall(), icon_url2,
2505 GetEdgeSizesLarge(), &favicon_bitmap_data);
2506
2507 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data);
2508
2509 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out;
2510 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url,
2511 favicon_base::FAVICON,
2512 GetEdgeSizesSmallAndLarge(),
2513 &bitmap_results_out));
2514
2515 // The results should have results for the icon URL with the large bitmap as
2516 // downscaling is preferred to upscaling.
2517 EXPECT_EQ(1u, bitmap_results_out.size());
2518 EXPECT_EQ(kLargeSize, bitmap_results_out[0].pixel_size);
2519 EXPECT_EQ(icon_url2, bitmap_results_out[0].icon_url);
2520 }
2521
2522 // Test the results of GetFaviconsFromDB() when called with different 2385 // Test the results of GetFaviconsFromDB() when called with different
2523 // |icon_types|. 2386 // |icon_types|.
2524 TEST_F(HistoryBackendTest, GetFaviconsFromDBIconType) { 2387 TEST_F(HistoryBackendTest, GetFaviconsFromDBIconType) {
2525 const GURL page_url("http://www.google.com/"); 2388 const GURL page_url("http://www.google.com/");
2526 const GURL icon_url1("http://www.google.com/icon1.png"); 2389 const GURL icon_url1("http://www.google.com/icon1.png");
2527 const GURL icon_url2("http://www.google.com/icon2.png"); 2390 const GURL icon_url2("http://www.google.com/icon2.png");
2391 std::vector<SkBitmap> bitmaps;
2392 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
2528 2393
2529 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 2394 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data;
2530 GenerateFaviconBitmapData(icon_url1, GetEdgeSizesSmall(), 2395 backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url1, bitmaps);
2531 &favicon_bitmap_data); 2396 backend_->SetFavicons(page_url, favicon_base::TOUCH_ICON, icon_url2, bitmaps);
2532 backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data);
2533
2534 GenerateFaviconBitmapData(
2535 icon_url2, GetEdgeSizesSmall(), &favicon_bitmap_data);
2536 backend_->SetFavicons(
2537 page_url, favicon_base::TOUCH_ICON, favicon_bitmap_data);
2538 2397
2539 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out; 2398 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out;
2540 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, 2399 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url,
2541 favicon_base::FAVICON, 2400 favicon_base::FAVICON,
2542 GetEdgeSizesSmallAndLarge(), 2401 GetEdgeSizesSmallAndLarge(),
2543 &bitmap_results_out)); 2402 &bitmap_results_out));
2544 2403
2545 EXPECT_EQ(1u, bitmap_results_out.size()); 2404 EXPECT_EQ(1u, bitmap_results_out.size());
2546 EXPECT_EQ(favicon_base::FAVICON, bitmap_results_out[0].icon_type); 2405 EXPECT_EQ(favicon_base::FAVICON, bitmap_results_out[0].icon_type);
2547 EXPECT_EQ(icon_url1, bitmap_results_out[0].icon_url); 2406 EXPECT_EQ(icon_url1, bitmap_results_out[0].icon_url);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2598 &bitmap_results); 2457 &bitmap_results);
2599 2458
2600 EXPECT_TRUE(bitmap_results.empty()); 2459 EXPECT_TRUE(bitmap_results.empty());
2601 } 2460 }
2602 2461
2603 TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) { 2462 TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) {
2604 const GURL url("http://www.google.com/"); 2463 const GURL url("http://www.google.com/");
2605 const GURL same_domain_url("http://www.google.com/subdir/index.html"); 2464 const GURL same_domain_url("http://www.google.com/subdir/index.html");
2606 const GURL foreign_domain_url("http://www.not-google.com/"); 2465 const GURL foreign_domain_url("http://www.not-google.com/");
2607 const GURL icon_url("http://www.google.com/icon.png"); 2466 const GURL icon_url("http://www.google.com/icon.png");
2467 std::vector<SkBitmap> bitmaps;
2468 bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
2608 2469
2609 // Add a favicon 2470 // Add a favicon
2610 std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data; 2471 backend_->SetFavicons(url, favicon_base::FAVICON, icon_url, bitmaps);
2611 GenerateFaviconBitmapData(icon_url, GetEdgeSizesSmall(),
2612 &favicon_bitmap_data);
2613 backend_->SetFavicons(url, favicon_base::FAVICON, favicon_bitmap_data);
2614 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( 2472 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(
2615 url, favicon_base::FAVICON, NULL)); 2473 url, favicon_base::FAVICON, NULL));
2616 2474
2617 // Validate starting state. 2475 // Validate starting state.
2618 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out; 2476 std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out;
2619 EXPECT_TRUE(backend_->GetFaviconsFromDB(url, 2477 EXPECT_TRUE(backend_->GetFaviconsFromDB(url,
2620 favicon_base::FAVICON, 2478 favicon_base::FAVICON,
2621 GetEdgeSizesSmallAndLarge(), 2479 GetEdgeSizesSmallAndLarge(),
2622 &bitmap_results_out)); 2480 &bitmap_results_out));
2623 EXPECT_FALSE(backend_->GetFaviconsFromDB(same_domain_url, 2481 EXPECT_FALSE(backend_->GetFaviconsFromDB(same_domain_url,
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 // Verify that the second term is no longer returned as result, and also check 3194 // Verify that the second term is no longer returned as result, and also check
3337 // at the low level that it is gone for good. The term corresponding to the 3195 // at the low level that it is gone for good. The term corresponding to the
3338 // first URLRow should not be affected. 3196 // first URLRow should not be affected.
3339 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); 3197 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1));
3340 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); 3198 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2));
3341 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); 3199 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL));
3342 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); 3200 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL));
3343 } 3201 }
3344 3202
3345 } // namespace history 3203 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698