| 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 <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 // data we'll put into the thumbnail database | 44 // data we'll put into the thumbnail database |
| 45 static const unsigned char blob1[] = | 45 static const unsigned char blob1[] = |
| 46 "12346102356120394751634516591348710478123649165419234519234512349134"; | 46 "12346102356120394751634516591348710478123649165419234519234512349134"; |
| 47 | 47 |
| 48 static const gfx::Size kSmallSize = gfx::Size(16, 16); | 48 static const gfx::Size kSmallSize = gfx::Size(16, 16); |
| 49 static const gfx::Size kLargeSize = gfx::Size(48, 48); | 49 static const gfx::Size kLargeSize = gfx::Size(48, 48); |
| 50 | 50 |
| 51 const std::string kSizesSmall = "16 16"; |
| 52 const std::string kSizesSmallAndLarge = "16 16 48 48"; |
| 53 |
| 51 } // namepace | 54 } // namepace |
| 52 | 55 |
| 53 namespace history { | 56 namespace history { |
| 54 | 57 |
| 55 class HistoryBackendTest; | 58 class HistoryBackendTest; |
| 56 | 59 |
| 57 // This must be a separate object since HistoryBackend manages its lifetime. | 60 // This must be a separate object since HistoryBackend manages its lifetime. |
| 58 // This just forwards the messages we're interested in to the test object. | 61 // This just forwards the messages we're interested in to the test object. |
| 59 class HistoryBackendTestDelegate : public HistoryBackend::Delegate { | 62 class HistoryBackendTestDelegate : public HistoryBackend::Delegate { |
| 60 public: | 63 public: |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 URLID id = backend_->db()->GetRowForURL(url, &row); | 197 URLID id = backend_->db()->GetRowForURL(url, &row); |
| 195 VisitVector visits; | 198 VisitVector visits; |
| 196 EXPECT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); | 199 EXPECT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); |
| 197 return visits[0].transition; | 200 return visits[0].transition; |
| 198 } | 201 } |
| 199 | 202 |
| 200 FilePath getTestDir() { | 203 FilePath getTestDir() { |
| 201 return test_dir_; | 204 return test_dir_; |
| 202 } | 205 } |
| 203 | 206 |
| 204 FaviconID GetFavicon(const GURL& url, IconType icon_type) { | 207 // Returns the number of icon mappings of |icon_type| to |page_url|. |
| 205 IconMapping icon_mapping; | 208 size_t NumIconMappingsForPageURL(const GURL& page_url, IconType icon_type) { |
| 206 if (backend_->thumbnail_db_->GetIconMappingForPageURL(url, icon_type, | 209 std::vector<IconMapping> icon_mappings; |
| 207 &icon_mapping)) | 210 if (backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, icon_type, |
| 208 return icon_mapping.icon_id; | 211 &icon_mappings)) { |
| 209 else | 212 return icon_mappings.size(); |
| 210 return 0; | 213 } |
| 214 return 0u; |
| 215 } |
| 216 |
| 217 // Returns true if there is exactly one favicon bitmap associated to |
| 218 // |icon_url|. If true, returns favicon bitmap in output parameter. |
| 219 bool GetOnlyFaviconBitmapForIconURL(const GURL& icon_url, |
| 220 IconType icon_type, |
| 221 FaviconBitmap* favicon_bitmap) { |
| 222 FaviconID id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( |
| 223 icon_url, icon_type); |
| 224 if (!id) |
| 225 return false; |
| 226 std::vector<FaviconBitmap> favicon_bitmaps; |
| 227 if (!backend_->thumbnail_db_->GetFaviconBitmaps(id, &favicon_bitmaps)) |
| 228 return false; |
| 229 if (favicon_bitmaps.size() != 1) |
| 230 return false; |
| 231 *favicon_bitmap = favicon_bitmaps[0]; |
| 232 return true; |
| 233 } |
| 234 |
| 235 // Deletes favicons and favicon bitmaps for |page_url| and |icon_type|. |
| 236 bool DeleteFaviconsAndFaviconBitmaps(const GURL& page_url, |
| 237 IconType icon_type) { |
| 238 backend_->SetFavicons(page_url, |
| 239 icon_type, |
| 240 std::vector<FaviconDataElement>(), |
| 241 IconURLSizesMap()); |
| 242 return !backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, |
| 243 icon_type, NULL); |
| 244 } |
| 245 |
| 246 // Sets the favicons for |page_url| and |icon_type|. This is very similar to |
| 247 // HistoryBackend::SetFavicons except that this call will delete favicon |
| 248 // bitmaps which are not in |elements|. This allows setting a favicon state |
| 249 // where a favicon bitmap can be guaranteed to be only specified via sizes and |
| 250 // not have any associated bitmap data in the favicon_bitmaps table. |
| 251 void SetFaviconsState(const GURL& page_url, |
| 252 IconType icon_type, |
| 253 const std::vector<FaviconDataElement>& elements, |
| 254 const IconURLSizesMap& icon_url_sizes) { |
| 255 EXPECT_TRUE(DeleteFaviconsAndFaviconBitmaps(page_url, icon_type)); |
| 256 backend_->SetFavicons(page_url, icon_type, elements, icon_url_sizes); |
| 257 } |
| 258 |
| 259 // Sets |elements| to have entries for the icon_urls and sizes specified. |
| 260 // The bitmap_data for entries are lowercase letters of the alphabet starting |
| 261 // at 'a' for the entry at index 0. |
| 262 void SetFaviconDataElements(const GURL& icon_url1, |
| 263 const FaviconSizes& icon_url1_sizes, |
| 264 std::vector<FaviconDataElement>* elements) { |
| 265 SetFaviconDataElements(icon_url1, icon_url1_sizes, GURL(), FaviconSizes(), |
| 266 elements); |
| 267 } |
| 268 |
| 269 void SetFaviconDataElements(const GURL& icon_url1, |
| 270 const FaviconSizes& icon_url1_sizes, |
| 271 const GURL& icon_url2, |
| 272 const FaviconSizes& icon_url2_sizes, |
| 273 std::vector<FaviconDataElement>* elements) { |
| 274 elements->clear(); |
| 275 |
| 276 char bitmap_char = 'a'; |
| 277 std::vector<gfx::Size> icon_url1_sizes_vector = icon_url1_sizes.ToVector(); |
| 278 for (size_t i = 0; i < icon_url1_sizes_vector.size(); ++i) { |
| 279 std::vector<unsigned char> data; |
| 280 data.push_back(bitmap_char); |
| 281 FaviconDataElement element; |
| 282 element.bitmap_data = base::RefCountedBytes::TakeVector(&data); |
| 283 element.pixel_size = icon_url1_sizes_vector[i]; |
| 284 element.icon_url = icon_url1; |
| 285 elements->push_back(element); |
| 286 |
| 287 ++bitmap_char; |
| 288 } |
| 289 |
| 290 std::vector<gfx::Size> icon_url2_sizes_vector = icon_url2_sizes.ToVector(); |
| 291 for (size_t i = 0; i < icon_url2_sizes_vector.size(); ++i) { |
| 292 std::vector<unsigned char> data; |
| 293 data.push_back(bitmap_char); |
| 294 FaviconDataElement element; |
| 295 element.bitmap_data = base::RefCountedBytes::TakeVector(&data); |
| 296 element.pixel_size = icon_url2_sizes_vector[i]; |
| 297 element.icon_url = icon_url2; |
| 298 elements->push_back(element); |
| 299 |
| 300 ++bitmap_char; |
| 301 } |
| 302 } |
| 303 |
| 304 // Returns true if |bitmap_data| is equal to |expected_data|. |
| 305 bool BitmapDataEqual(char expected_data, |
| 306 scoped_refptr<base::RefCountedMemory> bitmap_data) { |
| 307 return bitmap_data.get() && |
| 308 bitmap_data->size() == 1u && |
| 309 *bitmap_data->front() == expected_data; |
| 211 } | 310 } |
| 212 | 311 |
| 213 BookmarkModel bookmark_model_; | 312 BookmarkModel bookmark_model_; |
| 214 | 313 |
| 215 protected: | 314 protected: |
| 216 bool loaded_; | 315 bool loaded_; |
| 217 | 316 |
| 218 private: | 317 private: |
| 219 friend class HistoryBackendTestDelegate; | 318 friend class HistoryBackendTestDelegate; |
| 220 | 319 |
| 221 // testing::Test | 320 // testing::Test |
| 222 virtual void SetUp() { | 321 virtual void SetUp() { |
| 223 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), | 322 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), |
| 224 &test_dir_)) | 323 &test_dir_)) |
| 225 return; | 324 return; |
| 226 backend_ = new HistoryBackend(test_dir_, | 325 backend_ = new HistoryBackend(test_dir_, |
| 227 0, | 326 0, |
| 228 new HistoryBackendTestDelegate(this), | 327 new HistoryBackendTestDelegate(this), |
| 229 &bookmark_model_); | 328 &bookmark_model_); |
| 230 backend_->Init(std::string(), false); | 329 backend_->Init(std::string(), false); |
| 330 backend_->set_single_favicon_bitmap_per_icon_type(false); |
| 231 } | 331 } |
| 332 |
| 232 virtual void TearDown() { | 333 virtual void TearDown() { |
| 233 if (backend_.get()) | 334 if (backend_.get()) |
| 234 backend_->Closing(); | 335 backend_->Closing(); |
| 235 backend_ = NULL; | 336 backend_ = NULL; |
| 236 mem_backend_.reset(); | 337 mem_backend_.reset(); |
| 237 file_util::Delete(test_dir_, true); | 338 file_util::Delete(test_dir_, true); |
| 238 } | 339 } |
| 239 | 340 |
| 240 void SetInMemoryBackend(int backend_id, InMemoryHistoryBackend* backend) { | 341 void SetInMemoryBackend(int backend_id, InMemoryHistoryBackend* backend) { |
| 241 mem_backend_.reset(backend); | 342 mem_backend_.reset(backend); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 507 |
| 407 // All thumbnails should be deleted. | 508 // All thumbnails should be deleted. |
| 408 std::vector<unsigned char> out_data; | 509 std::vector<unsigned char> out_data; |
| 409 EXPECT_FALSE(backend_->thumbnail_db_->GetPageThumbnail(outrow1.id(), | 510 EXPECT_FALSE(backend_->thumbnail_db_->GetPageThumbnail(outrow1.id(), |
| 410 &out_data)); | 511 &out_data)); |
| 411 EXPECT_FALSE(backend_->thumbnail_db_->GetPageThumbnail(row2_id, &out_data)); | 512 EXPECT_FALSE(backend_->thumbnail_db_->GetPageThumbnail(row2_id, &out_data)); |
| 412 | 513 |
| 413 // We should have a favicon and favicon bitmaps for the first URL only. We | 514 // We should have a favicon and favicon bitmaps for the first URL only. We |
| 414 // look them up by favicon URL since the IDs may have changed. | 515 // look them up by favicon URL since the IDs may have changed. |
| 415 FaviconID out_favicon1 = backend_->thumbnail_db_-> | 516 FaviconID out_favicon1 = backend_->thumbnail_db_-> |
| 416 GetFaviconIDForFaviconURL(favicon_url1, FAVICON, NULL); | 517 GetFaviconIDForFaviconURL(favicon_url1, FAVICON); |
| 417 EXPECT_TRUE(out_favicon1); | 518 EXPECT_TRUE(out_favicon1); |
| 418 | 519 |
| 419 std::vector<FaviconBitmap> favicon_bitmaps; | 520 std::vector<FaviconBitmap> favicon_bitmaps; |
| 420 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps( | 521 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps( |
| 421 out_favicon1, &favicon_bitmaps)); | 522 out_favicon1, &favicon_bitmaps)); |
| 422 ASSERT_EQ(2u, favicon_bitmaps.size()); | 523 ASSERT_EQ(2u, favicon_bitmaps.size()); |
| 423 | 524 |
| 424 FaviconBitmap favicon_bitmap1 = favicon_bitmaps[0]; | 525 FaviconBitmap favicon_bitmap1 = favicon_bitmaps[0]; |
| 425 FaviconBitmap favicon_bitmap2 = favicon_bitmaps[1]; | 526 FaviconBitmap favicon_bitmap2 = favicon_bitmaps[1]; |
| 426 | 527 |
| 427 // Bitmaps do not need to be in particular order. | 528 // Favicon bitmaps do not need to be in particular order. |
| 428 if (favicon_bitmap1.pixel_size == kLargeSize) { | 529 if (favicon_bitmap1.pixel_size == kLargeSize) { |
| 429 FaviconBitmap tmp_favicon_bitmap = favicon_bitmap1; | 530 FaviconBitmap tmp_favicon_bitmap = favicon_bitmap1; |
| 430 favicon_bitmap1 = favicon_bitmap2; | 531 favicon_bitmap1 = favicon_bitmap2; |
| 431 favicon_bitmap2 = tmp_favicon_bitmap; | 532 favicon_bitmap2 = tmp_favicon_bitmap; |
| 432 } | 533 } |
| 433 | 534 |
| 434 EXPECT_EQ('a', *favicon_bitmap1.bitmap_data->front()); | 535 EXPECT_TRUE(BitmapDataEqual('a', favicon_bitmap1.bitmap_data)); |
| 435 EXPECT_EQ(kSmallSize, favicon_bitmap1.pixel_size); | 536 EXPECT_EQ(kSmallSize, favicon_bitmap1.pixel_size); |
| 436 | 537 |
| 437 EXPECT_EQ('b', *favicon_bitmap2.bitmap_data->front()); | 538 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap2.bitmap_data)); |
| 438 EXPECT_EQ(kLargeSize, favicon_bitmap2.pixel_size); | 539 EXPECT_EQ(kLargeSize, favicon_bitmap2.pixel_size); |
| 439 | 540 |
| 440 FaviconID out_favicon2 = backend_->thumbnail_db_-> | 541 FaviconID out_favicon2 = backend_->thumbnail_db_-> |
| 441 GetFaviconIDForFaviconURL(favicon_url2, FAVICON, NULL); | 542 GetFaviconIDForFaviconURL(favicon_url2, FAVICON); |
| 442 EXPECT_FALSE(out_favicon2) << "Favicon not deleted"; | 543 EXPECT_FALSE(out_favicon2) << "Favicon not deleted"; |
| 443 | 544 |
| 444 // The remaining URL should still reference the same favicon, even if its | 545 // The remaining URL should still reference the same favicon, even if its |
| 445 // ID has changed. | 546 // ID has changed. |
| 446 EXPECT_EQ(out_favicon1, GetFavicon(outrow1.url(), FAVICON)); | 547 std::vector<IconMapping> mappings; |
| 548 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 549 outrow1.url(), FAVICON, &mappings)); |
| 550 EXPECT_EQ(1u, mappings.size()); |
| 551 EXPECT_EQ(out_favicon1, mappings[0].icon_id); |
| 447 | 552 |
| 448 // The first URL should still be bookmarked. | 553 // The first URL should still be bookmarked. |
| 449 EXPECT_TRUE(bookmark_model_.IsBookmarked(row1.url())); | 554 EXPECT_TRUE(bookmark_model_.IsBookmarked(row1.url())); |
| 450 | 555 |
| 451 // The full text database should have no data. | 556 // The full text database should have no data. |
| 452 std::vector<TextDatabase::Match> text_matches; | 557 std::vector<TextDatabase::Match> text_matches; |
| 453 Time first_time_searched; | 558 Time first_time_searched; |
| 454 backend_->text_database_->GetTextMatches(UTF8ToUTF16("Body"), | 559 backend_->text_database_->GetTextMatches(UTF8ToUTF16("Body"), |
| 455 QueryOptions(), | 560 QueryOptions(), |
| 456 &text_matches, | 561 &text_matches, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 671 |
| 567 // Make sure url 2 is still valid, but has no visits. | 672 // Make sure url 2 is still valid, but has no visits. |
| 568 URLRow tmp_url_row; | 673 URLRow tmp_url_row; |
| 569 EXPECT_EQ(row2_id, backend_->db_->GetRowForURL(row2.url(), NULL)); | 674 EXPECT_EQ(row2_id, backend_->db_->GetRowForURL(row2.url(), NULL)); |
| 570 VisitVector visits; | 675 VisitVector visits; |
| 571 backend_->db_->GetVisitsForURL(row2_id, &visits); | 676 backend_->db_->GetVisitsForURL(row2_id, &visits); |
| 572 EXPECT_EQ(0U, visits.size()); | 677 EXPECT_EQ(0U, visits.size()); |
| 573 // The favicon should still be valid. | 678 // The favicon should still be valid. |
| 574 EXPECT_EQ(favicon2, | 679 EXPECT_EQ(favicon2, |
| 575 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url2, | 680 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url2, |
| 576 FAVICON, | 681 FAVICON)); |
| 577 NULL)); | |
| 578 | 682 |
| 579 // Unstar row2. | 683 // Unstar row2. |
| 580 bookmark_utils::RemoveAllBookmarks(&bookmark_model_, row2.url()); | 684 bookmark_utils::RemoveAllBookmarks(&bookmark_model_, row2.url()); |
| 581 | 685 |
| 582 // Tell the backend it was unstarred. We have to explicitly do this as | 686 // Tell the backend it was unstarred. We have to explicitly do this as |
| 583 // BookmarkModel isn't wired up to the backend during testing. | 687 // BookmarkModel isn't wired up to the backend during testing. |
| 584 std::set<GURL> unstarred_urls; | 688 std::set<GURL> unstarred_urls; |
| 585 unstarred_urls.insert(row2.url()); | 689 unstarred_urls.insert(row2.url()); |
| 586 backend_->URLsNoLongerBookmarked(unstarred_urls); | 690 backend_->URLsNoLongerBookmarked(unstarred_urls); |
| 587 | 691 |
| 588 // The URL should no longer exist. | 692 // The URL should no longer exist. |
| 589 EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &tmp_url_row)); | 693 EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &tmp_url_row)); |
| 590 // And the favicon should be deleted. | 694 // And the favicon should be deleted. |
| 591 EXPECT_EQ(0, | 695 EXPECT_EQ(0, |
| 592 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url2, | 696 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url2, |
| 593 FAVICON, | 697 FAVICON)); |
| 594 NULL)); | |
| 595 | 698 |
| 596 // Unstar row 1. | 699 // Unstar row 1. |
| 597 bookmark_utils::RemoveAllBookmarks(&bookmark_model_, row1.url()); | 700 bookmark_utils::RemoveAllBookmarks(&bookmark_model_, row1.url()); |
| 598 // Tell the backend it was unstarred. We have to explicitly do this as | 701 // Tell the backend it was unstarred. We have to explicitly do this as |
| 599 // BookmarkModel isn't wired up to the backend during testing. | 702 // BookmarkModel isn't wired up to the backend during testing. |
| 600 unstarred_urls.clear(); | 703 unstarred_urls.clear(); |
| 601 unstarred_urls.insert(row1.url()); | 704 unstarred_urls.insert(row1.url()); |
| 602 backend_->URLsNoLongerBookmarked(unstarred_urls); | 705 backend_->URLsNoLongerBookmarked(unstarred_urls); |
| 603 | 706 |
| 604 // The URL should still exist (because there were visits). | 707 // The URL should still exist (because there were visits). |
| 605 EXPECT_EQ(row1_id, backend_->db_->GetRowForURL(row1.url(), NULL)); | 708 EXPECT_EQ(row1_id, backend_->db_->GetRowForURL(row1.url(), NULL)); |
| 606 | 709 |
| 607 // There should still be visits. | 710 // There should still be visits. |
| 608 visits.clear(); | 711 visits.clear(); |
| 609 backend_->db_->GetVisitsForURL(row1_id, &visits); | 712 backend_->db_->GetVisitsForURL(row1_id, &visits); |
| 610 EXPECT_EQ(1U, visits.size()); | 713 EXPECT_EQ(1U, visits.size()); |
| 611 | 714 |
| 612 // The favicon should still be valid. | 715 // The favicon should still be valid. |
| 613 EXPECT_EQ(favicon1, | 716 EXPECT_EQ(favicon1, |
| 614 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url1, | 717 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url1, |
| 615 FAVICON, | 718 FAVICON)); |
| 616 NULL)); | |
| 617 } | 719 } |
| 618 | 720 |
| 619 // Tests a handful of assertions for a navigation with a type of | 721 // Tests a handful of assertions for a navigation with a type of |
| 620 // KEYWORD_GENERATED. | 722 // KEYWORD_GENERATED. |
| 621 TEST_F(HistoryBackendTest, KeywordGenerated) { | 723 TEST_F(HistoryBackendTest, KeywordGenerated) { |
| 622 ASSERT_TRUE(backend_.get()); | 724 ASSERT_TRUE(backend_.get()); |
| 623 | 725 |
| 624 GURL url("http://google.com"); | 726 GURL url("http://google.com"); |
| 625 | 727 |
| 626 Time visit_time = Time::Now() - base::TimeDelta::FromDays(1); | 728 Time visit_time = Time::Now() - base::TimeDelta::FromDays(1); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 URLRow row2(GURL("http://news.google.com/")); | 818 URLRow row2(GURL("http://news.google.com/")); |
| 717 row2.set_visit_count(1); | 819 row2.set_visit_count(1); |
| 718 row2.set_last_visit(Time::Now()); | 820 row2.set_last_visit(Time::Now()); |
| 719 URLRows rows; | 821 URLRows rows; |
| 720 rows.push_back(row1); | 822 rows.push_back(row1); |
| 721 rows.push_back(row2); | 823 rows.push_back(row2); |
| 722 backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED); | 824 backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED); |
| 723 URLRow url_row1, url_row2; | 825 URLRow url_row1, url_row2; |
| 724 EXPECT_FALSE(backend_->db_->GetRowForURL(row1.url(), &url_row1) == 0); | 826 EXPECT_FALSE(backend_->db_->GetRowForURL(row1.url(), &url_row1) == 0); |
| 725 EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &url_row2) == 0); | 827 EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &url_row2) == 0); |
| 726 EXPECT_FALSE(GetFavicon(row1.url(), FAVICON) == 0); | 828 EXPECT_EQ(1u, NumIconMappingsForPageURL(row1.url(), FAVICON)); |
| 727 EXPECT_TRUE(GetFavicon(row2.url(), FAVICON) == 0); | 829 EXPECT_EQ(0u, NumIconMappingsForPageURL(row2.url(), FAVICON)); |
| 728 | 830 |
| 729 // Now provide one imported favicon for both URLs already in the registry. | 831 // Now provide one imported favicon for both URLs already in the registry. |
| 730 // The new favicon should only be used with the URL that doesn't already have | 832 // The new favicon should only be used with the URL that doesn't already have |
| 731 // a favicon. | 833 // a favicon. |
| 732 std::vector<history::ImportedFaviconUsage> favicons; | 834 std::vector<history::ImportedFaviconUsage> favicons; |
| 733 history::ImportedFaviconUsage favicon; | 835 history::ImportedFaviconUsage favicon; |
| 734 favicon.favicon_url = GURL("http://news.google.com/favicon.ico"); | 836 favicon.favicon_url = GURL("http://news.google.com/favicon.ico"); |
| 735 favicon.png_data.push_back('2'); | 837 favicon.png_data.push_back('2'); |
| 736 favicon.urls.insert(row1.url()); | 838 favicon.urls.insert(row1.url()); |
| 737 favicon.urls.insert(row2.url()); | 839 favicon.urls.insert(row2.url()); |
| 738 favicons.push_back(favicon); | 840 favicons.push_back(favicon); |
| 739 backend_->SetImportedFavicons(favicons); | 841 backend_->SetImportedFavicons(favicons); |
| 740 EXPECT_FALSE(backend_->db_->GetRowForURL(row1.url(), &url_row1) == 0); | 842 EXPECT_FALSE(backend_->db_->GetRowForURL(row1.url(), &url_row1) == 0); |
| 741 EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &url_row2) == 0); | 843 EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &url_row2) == 0); |
| 742 EXPECT_FALSE(GetFavicon(row1.url(), FAVICON) == 0); | 844 |
| 743 EXPECT_FALSE(GetFavicon(row2.url(), FAVICON) == 0); | 845 std::vector<IconMapping> mappings; |
| 744 EXPECT_FALSE(GetFavicon(row1.url(), FAVICON) == | 846 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 745 GetFavicon(row2.url(), FAVICON)); | 847 row1.url(), FAVICON, &mappings)); |
| 848 EXPECT_EQ(1u, mappings.size()); |
| 849 EXPECT_EQ(favicon1, mappings[0].icon_id); |
| 850 EXPECT_EQ(favicon_url1, mappings[0].icon_url); |
| 851 |
| 852 mappings.clear(); |
| 853 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 854 row2.url(), FAVICON, &mappings)); |
| 855 EXPECT_EQ(1u, mappings.size()); |
| 856 EXPECT_EQ(favicon.favicon_url, mappings[0].icon_url); |
| 746 | 857 |
| 747 // A URL should not be added to history (to store favicon), if | 858 // A URL should not be added to history (to store favicon), if |
| 748 // the URL is not bookmarked. | 859 // the URL is not bookmarked. |
| 749 GURL url3("http://mail.google.com"); | 860 GURL url3("http://mail.google.com"); |
| 750 favicons.clear(); | 861 favicons.clear(); |
| 751 favicon.favicon_url = GURL("http://mail.google.com/favicon.ico"); | 862 favicon.favicon_url = GURL("http://mail.google.com/favicon.ico"); |
| 752 favicon.png_data.push_back('3'); | 863 favicon.png_data.push_back('3'); |
| 753 favicon.urls.insert(url3); | 864 favicon.urls.insert(url3); |
| 754 favicons.push_back(favicon); | 865 favicons.push_back(favicon); |
| 755 backend_->SetImportedFavicons(favicons); | 866 backend_->SetImportedFavicons(favicons); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 EXPECT_EQ(cur_version, file_version); | 1203 EXPECT_EQ(cur_version, file_version); |
| 1093 | 1204 |
| 1094 // Check visit_source table is created and empty. | 1205 // Check visit_source table is created and empty. |
| 1095 s.Assign(db.GetUniqueStatement( | 1206 s.Assign(db.GetUniqueStatement( |
| 1096 "SELECT name FROM sqlite_master WHERE name=\"visit_source\"")); | 1207 "SELECT name FROM sqlite_master WHERE name=\"visit_source\"")); |
| 1097 ASSERT_TRUE(s.Step()); | 1208 ASSERT_TRUE(s.Step()); |
| 1098 s.Assign(db.GetUniqueStatement("SELECT * FROM visit_source LIMIT 10")); | 1209 s.Assign(db.GetUniqueStatement("SELECT * FROM visit_source LIMIT 10")); |
| 1099 EXPECT_FALSE(s.Step()); | 1210 EXPECT_FALSE(s.Step()); |
| 1100 } | 1211 } |
| 1101 | 1212 |
| 1102 TEST_F(HistoryBackendTest, SetFaviconMapping) { | 1213 // Test that SetFaviconMappingsForPageAndRedirects correctly updates icon |
| 1214 // mappings based on redirects, icon URLs and icon types. |
| 1215 TEST_F(HistoryBackendTest, SetFaviconMappingsForPageAndRedirects) { |
| 1103 // Init recent_redirects_ | 1216 // Init recent_redirects_ |
| 1104 const GURL url1("http://www.google.com"); | 1217 const GURL url1("http://www.google.com"); |
| 1105 const GURL url2("http://www.google.com/m"); | 1218 const GURL url2("http://www.google.com/m"); |
| 1106 URLRow url_info1(url1); | 1219 URLRow url_info1(url1); |
| 1107 url_info1.set_visit_count(0); | 1220 url_info1.set_visit_count(0); |
| 1108 url_info1.set_typed_count(0); | 1221 url_info1.set_typed_count(0); |
| 1109 url_info1.set_last_visit(base::Time()); | 1222 url_info1.set_last_visit(base::Time()); |
| 1110 url_info1.set_hidden(false); | 1223 url_info1.set_hidden(false); |
| 1111 backend_->db_->AddURL(url_info1); | 1224 backend_->db_->AddURL(url_info1); |
| 1112 | 1225 |
| 1113 URLRow url_info2(url2); | 1226 URLRow url_info2(url2); |
| 1114 url_info2.set_visit_count(0); | 1227 url_info2.set_visit_count(0); |
| 1115 url_info2.set_typed_count(0); | 1228 url_info2.set_typed_count(0); |
| 1116 url_info2.set_last_visit(base::Time()); | 1229 url_info2.set_last_visit(base::Time()); |
| 1117 url_info2.set_hidden(false); | 1230 url_info2.set_hidden(false); |
| 1118 backend_->db_->AddURL(url_info2); | 1231 backend_->db_->AddURL(url_info2); |
| 1119 | 1232 |
| 1120 history::RedirectList redirects; | 1233 history::RedirectList redirects; |
| 1121 redirects.push_back(url2); | 1234 redirects.push_back(url2); |
| 1122 redirects.push_back(url1); | 1235 redirects.push_back(url1); |
| 1123 backend_->recent_redirects_.Put(url1, redirects); | 1236 backend_->recent_redirects_.Put(url1, redirects); |
| 1124 | 1237 |
| 1125 const GURL icon_url("http://www.google.com/icon"); | 1238 const GURL icon_url1("http://www.google.com/icon"); |
| 1126 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); | 1239 const GURL icon_url2("http://www.google.com/icon2"); |
| 1127 // Add a favicon | 1240 |
| 1128 backend_->SetFavicon( | 1241 // Create mapping for a page with two favicons. |
| 1129 url1, icon_url, base::RefCountedBytes::TakeVector(&data), FAVICON); | 1242 IconURLSizesMap two_icon_url_sizes; |
| 1130 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1243 two_icon_url_sizes[icon_url1] = FaviconSizes(kSizesSmallAndLarge); |
| 1131 url1, FAVICON, NULL)); | 1244 two_icon_url_sizes[icon_url2] = FaviconSizes(kSizesSmallAndLarge); |
| 1132 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1245 |
| 1133 url2, FAVICON, NULL)); | 1246 // Create a mapping for a page with a single favicon. |
| 1134 | 1247 IconURLSizesMap one_icon_url_sizes; |
| 1135 // Add a touch_icon | 1248 one_icon_url_sizes[icon_url1] = FaviconSizes(kSizesSmallAndLarge); |
| 1136 backend_->SetFavicon( | 1249 |
| 1137 url1, icon_url, base::RefCountedBytes::TakeVector(&data), TOUCH_ICON); | 1250 std::vector<FaviconDataElement> elements; |
| 1138 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1251 |
| 1139 url1, TOUCH_ICON, NULL)); | 1252 // Add two favicons |
| 1140 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1253 backend_->SetFavicons(url1, FAVICON, elements, two_icon_url_sizes); |
| 1141 url2, TOUCH_ICON, NULL)); | 1254 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); |
| 1142 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1255 EXPECT_EQ(2u, NumIconMappingsForPageURL(url2, FAVICON)); |
| 1143 url1, FAVICON, NULL)); | 1256 |
| 1144 | 1257 // Add one touch_icon |
| 1145 // Add a TOUCH_PRECOMPOSED_ICON | 1258 backend_->SetFavicons(url1, TOUCH_ICON, elements, one_icon_url_sizes); |
| 1146 backend_->SetFavicon(url1, | 1259 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, TOUCH_ICON)); |
| 1147 icon_url, | 1260 EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, TOUCH_ICON)); |
| 1148 base::RefCountedBytes::TakeVector(&data), | 1261 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); |
| 1149 TOUCH_PRECOMPOSED_ICON); | 1262 |
| 1263 // Add one TOUCH_PRECOMPOSED_ICON |
| 1264 backend_->SetFavicons(url1, TOUCH_PRECOMPOSED_ICON, elements, |
| 1265 one_icon_url_sizes); |
| 1150 // The touch_icon was replaced. | 1266 // The touch_icon was replaced. |
| 1151 EXPECT_FALSE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1267 EXPECT_EQ(0u, NumIconMappingsForPageURL(url1, TOUCH_ICON)); |
| 1152 url1, TOUCH_ICON, NULL)); | 1268 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); |
| 1153 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1269 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, TOUCH_PRECOMPOSED_ICON)); |
| 1154 url1, FAVICON, NULL)); | 1270 EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, TOUCH_PRECOMPOSED_ICON)); |
| 1155 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1271 |
| 1156 url1, TOUCH_PRECOMPOSED_ICON, NULL)); | 1272 // Add a touch_icon. |
| 1157 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1273 backend_->SetFavicons(url1, TOUCH_ICON, elements, one_icon_url_sizes); |
| 1158 url2, TOUCH_PRECOMPOSED_ICON, NULL)); | 1274 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, TOUCH_ICON)); |
| 1159 | 1275 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); |
| 1160 // Add a touch_icon | |
| 1161 backend_->SetFavicon( | |
| 1162 url1, icon_url, base::RefCountedBytes::TakeVector(&data), TOUCH_ICON); | |
| 1163 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | |
| 1164 url1, TOUCH_ICON, NULL)); | |
| 1165 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | |
| 1166 url1, FAVICON, NULL)); | |
| 1167 // The TOUCH_PRECOMPOSED_ICON was replaced. | 1276 // The TOUCH_PRECOMPOSED_ICON was replaced. |
| 1168 EXPECT_FALSE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1277 EXPECT_EQ(0u, NumIconMappingsForPageURL(url1, TOUCH_PRECOMPOSED_ICON)); |
| 1169 url1, TOUCH_PRECOMPOSED_ICON, NULL)); | 1278 |
| 1170 | 1279 // Add a single favicon. |
| 1171 // Add a favicon | 1280 backend_->SetFavicons(url1, FAVICON, elements, one_icon_url_sizes); |
| 1172 const GURL icon_url2("http://www.google.com/icon2"); | 1281 // The favicon of type FAVICON for |icon_url2| should have no more mappings |
| 1173 backend_->SetFavicon( | 1282 // and should have been deleted. |
| 1174 url1, icon_url2, base::RefCountedBytes::TakeVector(&data), FAVICON); | 1283 EXPECT_EQ(0, backend_->thumbnail_db_->GetFaviconIDForFaviconURL(icon_url2, |
| 1175 FaviconID icon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( | 1284 FAVICON)); |
| 1176 icon_url2, FAVICON, NULL); | 1285 // The remaining mapping should be |icon_url1|. |
| 1177 EXPECT_NE(0, icon_id); | 1286 std::vector<IconMapping> icon_mappings; |
| 1178 std::vector<IconMapping> icon_mapping; | |
| 1179 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( | 1287 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 1180 url1, &icon_mapping)); | 1288 url1, FAVICON, &icon_mappings)); |
| 1181 // The old icon was replaced. | 1289 EXPECT_EQ(1u, icon_mappings.size()); |
| 1182 EXPECT_TRUE(icon_mapping.size() > 1); | 1290 EXPECT_EQ(icon_url1, icon_mappings[0].icon_url); |
| 1183 EXPECT_EQ(icon_id, icon_mapping[1].icon_id); | 1291 |
| 1184 } | 1292 // Add two favicons. |
| 1185 | 1293 backend_->SetFavicons(url1, FAVICON, elements, two_icon_url_sizes); |
| 1186 TEST_F(HistoryBackendTest, AddOrUpdateIconMapping) { | 1294 EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, TOUCH_ICON)); |
| 1187 // Test the same icon and page mapping will not be added twice. other case | 1295 EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); |
| 1188 // should be covered in TEST_F(HistoryBackendTest, SetFaviconMapping) | 1296 } |
| 1297 |
| 1298 // Test that there is no churn in icon mappings from calling |
| 1299 // SetFaviconMappingsForPage() with icon mappings which are already in the |
| 1300 // database. |
| 1301 TEST_F(HistoryBackendTest, SetFaviconMappingsForPageDuplicates) { |
| 1189 const GURL url("http://www.google.com/"); | 1302 const GURL url("http://www.google.com/"); |
| 1190 const GURL icon_url("http://www.google.com/icon"); | 1303 const GURL icon_url("http://www.google.com/icon"); |
| 1191 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); | 1304 std::vector<FaviconDataElement> elements; |
| 1192 | 1305 |
| 1193 backend_->SetFavicon( | 1306 IconURLSizesMap icon_url_sizes; |
| 1194 url, icon_url, base::RefCountedBytes::TakeVector(&data), FAVICON); | 1307 icon_url_sizes[icon_url] = FaviconSizes(kSizesSmallAndLarge); |
| 1195 FaviconID icon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( | 1308 |
| 1196 icon_url, FAVICON, NULL); | 1309 backend_->SetFavicons(url, FAVICON, elements, icon_url_sizes); |
| 1197 | 1310 |
| 1198 // Add the same mapping | 1311 std::vector<IconMapping> icon_mappings; |
| 1199 FaviconID replaced; | |
| 1200 EXPECT_FALSE(backend_->AddOrUpdateIconMapping( | |
| 1201 url, icon_id, FAVICON, &replaced)); | |
| 1202 EXPECT_EQ(0, replaced); | |
| 1203 | |
| 1204 std::vector<IconMapping> icon_mapping; | |
| 1205 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( | 1312 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 1206 url, &icon_mapping)); | 1313 url, FAVICON, &icon_mappings)); |
| 1207 EXPECT_EQ(1u, icon_mapping.size()); | 1314 EXPECT_EQ(1u, icon_mappings.size()); |
| 1208 } | 1315 IconMappingID mapping_id = icon_mappings[0].mapping_id; |
| 1209 | 1316 GURL favicon_url = icon_mappings[0].icon_url; |
| 1210 TEST_F(HistoryBackendTest, GetFaviconForURL) { | 1317 FaviconID favicon_id = icon_mappings[0].icon_id; |
| 1211 // This test will add a fav icon and touch icon for the same URL | 1318 |
| 1212 // and check the behaviour of backend's GetFaviconForURL implementation. | 1319 HistoryBackend::IconURLFaviconIDMap icon_url_ids; |
| 1213 const GURL url("http://www.google.com/"); | 1320 icon_url_ids[favicon_url] = favicon_id; |
| 1321 |
| 1322 // False should be returned as no mappings should have changed. |
| 1323 EXPECT_FALSE(backend_->SetFaviconMappingsForPage(url, FAVICON, icon_url_ids)); |
| 1324 |
| 1325 icon_mappings.clear(); |
| 1326 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 1327 url, FAVICON, &icon_mappings)); |
| 1328 EXPECT_EQ(1u, icon_mappings.size()); |
| 1329 |
| 1330 // The same row in the icon_mapping table should be used for the mapping as |
| 1331 // before. |
| 1332 EXPECT_EQ(mapping_id, icon_mappings[0].mapping_id); |
| 1333 } |
| 1334 |
| 1335 // Test that setting favicons for a page which already has data does the |
| 1336 // right thing. |
| 1337 TEST_F(HistoryBackendTest, SetFavicons) { |
| 1338 const GURL page_url("http://www.google.com/"); |
| 1339 std::vector<FaviconDataElement> elements; |
| 1340 IconURLSizesMap icon_url_sizes; |
| 1341 |
| 1342 EXPECT_TRUE(DeleteFaviconsAndFaviconBitmaps(page_url, FAVICON)); |
| 1343 |
| 1344 // Set |page_url| as having two favicons each available from the web at two |
| 1345 // sizes. |
| 1346 const GURL icon_url1("http://www.google.com/icon1"); |
| 1347 const GURL icon_url2("http://www.google.com/icon2"); |
| 1348 |
| 1349 icon_url_sizes[icon_url1] = FaviconSizes(kSizesSmallAndLarge); |
| 1350 icon_url_sizes[icon_url2] = FaviconSizes(kSizesSmallAndLarge); |
| 1351 |
| 1352 // Set only sizes info for the favicons. |
| 1353 backend_->SetFavicons(page_url, FAVICON, elements, icon_url_sizes); |
| 1354 |
| 1355 std::vector<IconMapping> icon_mappings; |
| 1356 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 1357 page_url, &icon_mappings)); |
| 1358 EXPECT_EQ(2u, icon_mappings.size()); |
| 1359 for (size_t i = 0; i < icon_mappings.size(); ++i) { |
| 1360 EXPECT_FALSE(backend_->thumbnail_db_->GetFaviconBitmaps( |
| 1361 icon_mappings[i].icon_id, NULL)); |
| 1362 } |
| 1363 |
| 1364 // Add bitmap data to the favicons. |
| 1365 SetFaviconDataElements(icon_url1, |
| 1366 FaviconSizes(kSizesSmall), |
| 1367 icon_url2, |
| 1368 FaviconSizes(kSizesSmallAndLarge), |
| 1369 &elements); |
| 1370 |
| 1371 backend_->SetFavicons(page_url, FAVICON, elements, icon_url_sizes); |
| 1372 |
| 1373 icon_mappings.clear(); |
| 1374 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 1375 page_url, &icon_mappings)); |
| 1376 EXPECT_EQ(2u, icon_mappings.size()); |
| 1377 IconMapping mapping1 = icon_mappings[0]; |
| 1378 IconMapping mapping2 = icon_mappings[1]; |
| 1379 |
| 1380 // Icon mappings do not need to be returned in particular order from database |
| 1381 // with respect to icon url. |
| 1382 if (mapping1.icon_url == icon_url2) { |
| 1383 IconMapping tmp_mapping = mapping1; |
| 1384 mapping1 = mapping2; |
| 1385 mapping2 = tmp_mapping; |
| 1386 } |
| 1387 |
| 1388 GURL icon_url; |
| 1389 IconType icon_type; |
| 1390 std::string sizes; |
| 1391 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconHeader(mapping1.icon_id, |
| 1392 &icon_url, &icon_type, &sizes)); |
| 1393 EXPECT_EQ(icon_url1, icon_url); |
| 1394 EXPECT_EQ(FAVICON, icon_type); |
| 1395 EXPECT_EQ(kSizesSmallAndLarge, sizes); |
| 1396 |
| 1397 std::vector<FaviconBitmap> favicon_bitmaps; |
| 1398 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps(mapping1.icon_id, |
| 1399 &favicon_bitmaps)); |
| 1400 EXPECT_EQ(1u, favicon_bitmaps.size()); |
| 1401 EXPECT_TRUE(BitmapDataEqual('a', favicon_bitmaps[0].bitmap_data)); |
| 1402 EXPECT_EQ(kSmallSize, favicon_bitmaps[0].pixel_size); |
| 1403 |
| 1404 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconHeader(mapping2.icon_id, |
| 1405 &icon_url, &icon_type, &sizes)); |
| 1406 EXPECT_EQ(icon_url2, icon_url); |
| 1407 EXPECT_EQ(FAVICON, icon_type); |
| 1408 EXPECT_EQ(kSizesSmallAndLarge, sizes); |
| 1409 |
| 1410 favicon_bitmaps.clear(); |
| 1411 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps(mapping2.icon_id, |
| 1412 &favicon_bitmaps)); |
| 1413 |
| 1414 EXPECT_EQ(2u, favicon_bitmaps.size()); |
| 1415 |
| 1416 // Favicon bitmaps do not need to be in particular order. |
| 1417 if (favicon_bitmaps[0].pixel_size == kSmallSize) { |
| 1418 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmaps[0].bitmap_data)); |
| 1419 EXPECT_EQ(kLargeSize, favicon_bitmaps[1].pixel_size); |
| 1420 EXPECT_TRUE(BitmapDataEqual('c', favicon_bitmaps[1].bitmap_data)); |
| 1421 } else { |
| 1422 EXPECT_EQ(kLargeSize, favicon_bitmaps[0].pixel_size); |
| 1423 EXPECT_TRUE(BitmapDataEqual('c', favicon_bitmaps[0].bitmap_data)); |
| 1424 EXPECT_EQ(kSmallSize, favicon_bitmaps[1].pixel_size); |
| 1425 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmaps[1].bitmap_data)); |
| 1426 } |
| 1427 |
| 1428 // Change the sizes for which the favicon at icon_url1 is available at from |
| 1429 // the web. Verify that all the data remains valid. |
| 1430 const std::string kSizesTinySmallAndLarge = "10 10 " + kSizesSmallAndLarge; |
| 1431 icon_url_sizes[icon_url1] = FaviconSizes(kSizesTinySmallAndLarge); |
| 1432 elements.clear(); |
| 1433 backend_->SetFavicons(page_url, FAVICON, elements, icon_url_sizes); |
| 1434 |
| 1435 icon_mappings.clear(); |
| 1436 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 1437 page_url, &icon_mappings)); |
| 1438 EXPECT_EQ(2u, icon_mappings.size()); |
| 1439 mapping1 = icon_mappings[0]; |
| 1440 mapping2 = icon_mappings[1]; |
| 1441 |
| 1442 // Icon mappings do not need to be returned in particular order from database |
| 1443 // with respect to icon urls. |
| 1444 if (mapping1.icon_url == icon_url2) { |
| 1445 IconMapping tmp_mapping = mapping1; |
| 1446 mapping1 = mapping2; |
| 1447 mapping2 = tmp_mapping; |
| 1448 } |
| 1449 |
| 1450 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconHeader(mapping1.icon_id, |
| 1451 &icon_url, &icon_type, &sizes)); |
| 1452 EXPECT_EQ(icon_url1, icon_url); |
| 1453 EXPECT_EQ(FAVICON, icon_type); |
| 1454 EXPECT_EQ(kSizesTinySmallAndLarge, sizes); |
| 1455 |
| 1456 favicon_bitmaps.clear(); |
| 1457 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps(mapping1.icon_id, |
| 1458 &favicon_bitmaps)); |
| 1459 EXPECT_EQ(1u, favicon_bitmaps.size()); |
| 1460 |
| 1461 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconHeader(mapping2.icon_id, |
| 1462 &icon_url, &icon_type, &sizes)); |
| 1463 EXPECT_EQ(icon_url2, icon_url); |
| 1464 EXPECT_EQ(FAVICON, icon_type); |
| 1465 EXPECT_EQ(kSizesSmallAndLarge, sizes); |
| 1466 |
| 1467 favicon_bitmaps.clear(); |
| 1468 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps(mapping2.icon_id, |
| 1469 &favicon_bitmaps)); |
| 1470 EXPECT_EQ(2u, favicon_bitmaps.size()); |
| 1471 } |
| 1472 |
| 1473 // Test that changing the sizes that a favicon is available at from the web |
| 1474 // deletes stale favicon bitmaps. |
| 1475 TEST_F(HistoryBackendTest, SetFaviconsDeleteBitmaps) { |
| 1476 const GURL page_url("http://www.google.com/"); |
| 1214 const GURL icon_url("http://www.google.com/icon"); | 1477 const GURL icon_url("http://www.google.com/icon"); |
| 1215 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); | 1478 |
| 1216 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); | 1479 // Set |page_url| as having one favicon with two different sizes. |
| 1217 // Used for testing the icon data after getting from DB | 1480 IconURLSizesMap icon_url_sizes; |
| 1218 std::string blob_data(bytes->front(), | 1481 icon_url_sizes[icon_url] = FaviconSizes(kSizesSmallAndLarge); |
| 1219 bytes->front() + bytes->size()); | 1482 |
| 1220 | 1483 std::vector<FaviconDataElement> elements; |
| 1221 // Add a favicon | 1484 SetFaviconDataElements(icon_url, FaviconSizes(kSizesSmallAndLarge), |
| 1222 backend_->SetFavicon( | 1485 &elements); |
| 1223 url, icon_url, bytes.get(), FAVICON); | 1486 |
| 1224 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1487 // Add bitmap data and sizes information to the database. |
| 1225 url, FAVICON, NULL)); | 1488 backend_->SetFavicons(page_url, FAVICON, elements, icon_url_sizes); |
| 1226 | 1489 |
| 1227 // Add a touch_icon | 1490 FaviconID favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( |
| 1228 backend_->SetFavicon( | 1491 icon_url, FAVICON); |
| 1229 url, icon_url, bytes.get(), TOUCH_ICON); | 1492 EXPECT_NE(0, favicon_id); |
| 1230 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1493 |
| 1231 url, TOUCH_ICON, NULL)); | 1494 std::vector<FaviconBitmap> favicon_bitmaps; |
| 1232 | 1495 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps(favicon_id, |
| 1233 // Test the Fav icon for this URL. | 1496 &favicon_bitmaps)); |
| 1234 FaviconData favicon; | 1497 EXPECT_EQ(2u, favicon_bitmaps.size()); |
| 1235 ASSERT_TRUE(backend_->GetFaviconFromDB(url, FAVICON, &favicon)); | 1498 |
| 1236 std::string favicon_data( | 1499 // Change the bitmap sizes avaible from the web only to the small size only. |
| 1237 favicon.image_data->front(), | 1500 icon_url_sizes[icon_url] = FaviconSizes(kSizesSmall); |
| 1238 favicon.image_data->front() + favicon.image_data->size()); | 1501 elements.clear(); |
| 1239 | 1502 backend_->SetFavicons(page_url, FAVICON, elements, icon_url_sizes); |
| 1240 EXPECT_EQ(FAVICON, favicon.icon_type); | 1503 |
| 1241 EXPECT_EQ(icon_url, favicon.icon_url); | 1504 favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, |
| 1242 EXPECT_EQ(blob_data, favicon_data); | 1505 FAVICON); |
| 1243 | 1506 EXPECT_NE(0, favicon_id); |
| 1244 // Test the touch icon for this URL. | 1507 |
| 1245 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); | 1508 favicon_bitmaps.clear(); |
| 1246 std::string touchicon_data( | 1509 EXPECT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps(favicon_id, |
| 1247 favicon.image_data->front(), | 1510 &favicon_bitmaps)); |
| 1248 favicon.image_data->front() + favicon.image_data->size()); | 1511 EXPECT_EQ(1u, favicon_bitmaps.size()); |
| 1249 | 1512 EXPECT_EQ(kSmallSize, favicon_bitmaps[0].pixel_size); |
| 1250 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); | 1513 } |
| 1251 EXPECT_EQ(icon_url, favicon.icon_url); | 1514 |
| 1252 EXPECT_EQ(blob_data, touchicon_data); | 1515 // Test updating a single favicon bitmap's data via SetFavicons. |
| 1516 TEST_F(HistoryBackendTest, SetFaviconsReplaceBitmapData) { |
| 1517 |
| 1518 const GURL page_url("http://www.google.com/"); |
| 1519 const GURL icon_url("http://www.google.com/icon"); |
| 1520 IconURLSizesMap icon_url_sizes; |
| 1521 icon_url_sizes[icon_url] = FaviconSizes(kSizesSmall); |
| 1522 |
| 1523 std::vector<unsigned char> data_initial; |
| 1524 data_initial.push_back('a'); |
| 1525 |
| 1526 FaviconDataElement element; |
| 1527 element.bitmap_data = base::RefCountedBytes::TakeVector(&data_initial); |
| 1528 element.pixel_size = kSmallSize; |
| 1529 element.icon_url = icon_url; |
| 1530 std::vector<FaviconDataElement> elements; |
| 1531 elements.push_back(element); |
| 1532 |
| 1533 // Add bitmap to the database. |
| 1534 backend_->SetFavicons(page_url, FAVICON, elements, icon_url_sizes); |
| 1535 |
| 1536 FaviconBitmap favicon_bitmap; |
| 1537 EXPECT_TRUE(GetOnlyFaviconBitmapForIconURL(icon_url, FAVICON, |
| 1538 &favicon_bitmap)); |
| 1539 EXPECT_TRUE(BitmapDataEqual('a', favicon_bitmap.bitmap_data)); |
| 1540 |
| 1541 // SetFavicons with identical data but a different bitmap. |
| 1542 std::vector<unsigned char> updated_data; |
| 1543 updated_data.push_back('b'); |
| 1544 elements[0].bitmap_data = base::RefCountedBytes::TakeVector(&updated_data); |
| 1545 backend_->SetFavicons(page_url, FAVICON, elements, icon_url_sizes); |
| 1546 |
| 1547 EXPECT_TRUE(GetOnlyFaviconBitmapForIconURL(icon_url, FAVICON, |
| 1548 &favicon_bitmap)); |
| 1549 EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap.bitmap_data)); |
| 1550 } |
| 1551 |
| 1552 // Test GetFaviconsFromDB returns expected data in FaviconData. |
| 1553 TEST_F(HistoryBackendTest, GetFaviconsFromDB) { |
| 1554 const GURL page_url("http://www.google.com/"); |
| 1555 |
| 1556 // |page_url| has favicons at two different icon URLs on the web. Each icon |
| 1557 // is a .ico file with two bitmaps. |
| 1558 const GURL icon_url1("http://www.google.com/icon1.ico"); |
| 1559 const GURL icon_url2("http://www.google.com/icon2.ico"); |
| 1560 |
| 1561 IconURLSizesMap icon_url_sizes; |
| 1562 icon_url_sizes[icon_url1] = FaviconSizes(kSizesSmallAndLarge); |
| 1563 icon_url_sizes[icon_url2] = FaviconSizes(kSizesSmallAndLarge); |
| 1564 |
| 1565 // The thumbnail database has stored bitmap data only for the favicon at |
| 1566 // |icon_url1|. |
| 1567 std::vector<FaviconDataElement> elements; |
| 1568 SetFaviconDataElements(icon_url1, FaviconSizes(kSizesSmallAndLarge), |
| 1569 &elements); |
| 1570 |
| 1571 SetFaviconsState(page_url, FAVICON, elements, icon_url_sizes); |
| 1572 |
| 1573 FaviconData favicon_data; |
| 1574 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, FAVICON, &favicon_data)); |
| 1575 |
| 1576 EXPECT_TRUE(favicon_data.known_icon); |
| 1577 EXPECT_FALSE(favicon_data.expired); |
| 1578 EXPECT_EQ(FAVICON, favicon_data.icon_type); |
| 1579 |
| 1580 EXPECT_EQ(2u, favicon_data.elements.size()); |
| 1581 FaviconDataElement element1 = favicon_data.elements[0]; |
| 1582 FaviconDataElement element2 = favicon_data.elements[1]; |
| 1583 |
| 1584 // No required order for FaviconDataElements. |
| 1585 if (element1.pixel_size == kLargeSize) { |
| 1586 FaviconDataElement tmp_element = element1; |
| 1587 element1 = element2; |
| 1588 element2 = tmp_element; |
| 1589 } |
| 1590 |
| 1591 EXPECT_TRUE(BitmapDataEqual('a', element1.bitmap_data)); |
| 1592 EXPECT_EQ(kSmallSize, element1.pixel_size); |
| 1593 EXPECT_EQ(icon_url1, element1.icon_url); |
| 1594 |
| 1595 EXPECT_TRUE(BitmapDataEqual('b', element2.bitmap_data)); |
| 1596 EXPECT_EQ(kLargeSize, element2.pixel_size); |
| 1597 EXPECT_EQ(icon_url1, element2.icon_url); |
| 1598 |
| 1599 EXPECT_EQ(2u, favicon_data.icon_url_sizes.size()); |
| 1600 EXPECT_TRUE(favicon_data.icon_url_sizes.count(icon_url1)); |
| 1601 EXPECT_EQ(kSizesSmallAndLarge, |
| 1602 favicon_data.icon_url_sizes[icon_url1].ToString()); |
| 1603 EXPECT_TRUE(favicon_data.icon_url_sizes.count(icon_url2)); |
| 1604 EXPECT_EQ(kSizesSmallAndLarge, |
| 1605 favicon_data.icon_url_sizes[icon_url2].ToString()); |
| 1606 } |
| 1607 |
| 1608 // Tests that |expired| == true in FaviconData returned by GetFaviconsFromDB |
| 1609 // when one of the favicons are out of date. |
| 1610 TEST_F(HistoryBackendTest, GetFaviconsFromDBExpired) { |
| 1611 const GURL page_url("http://www.google.com/"); |
| 1612 |
| 1613 // |page_url| has favicons at two different icon URLs on the web. Each icon |
| 1614 // is a .png with a single bitmap. |
| 1615 const GURL icon_url1("http://www.google.com/icon1.png"); |
| 1616 const GURL icon_url2("http://www.google.com/icon2.png"); |
| 1617 |
| 1618 IconURLSizesMap icon_url_sizes; |
| 1619 icon_url_sizes[icon_url1] = FaviconSizes(kSizesSmall); |
| 1620 icon_url_sizes[icon_url2] = FaviconSizes(kSizesSmall); |
| 1621 |
| 1622 std::vector<FaviconDataElement> elements; |
| 1623 SetFaviconDataElements(icon_url1, FaviconSizes(kSizesSmall), icon_url2, |
| 1624 FaviconSizes(kSizesSmall), &elements); |
| 1625 |
| 1626 SetFaviconsState(page_url, FAVICON, elements, icon_url_sizes); |
| 1627 |
| 1628 // Set the favicon for |icon_url1| as out of date. |
| 1629 FaviconID favicon_id1 = |
| 1630 backend_->thumbnail_db_->GetFaviconIDForFaviconURL(icon_url1, FAVICON); |
| 1631 EXPECT_NE(0, favicon_id1); |
| 1632 EXPECT_TRUE(backend_->thumbnail_db_->SetFaviconOutOfDate(favicon_id1)); |
| 1633 |
| 1634 FaviconData favicon_data; |
| 1635 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, FAVICON, &favicon_data)); |
| 1636 // Favicon should be expired. |
| 1637 EXPECT_TRUE(favicon_data.expired); |
| 1638 } |
| 1639 |
| 1640 // Test FaviconData returned by GetFaviconsFromDB for different IconTypes. |
| 1641 TEST_F(HistoryBackendTest, GetFaviconsFromDBIconType) { |
| 1642 const GURL page_url("http://www.google.com/"); |
| 1643 const GURL icon_url1("http://www.google.com/icon1.png"); |
| 1644 const GURL icon_url2("http://www.google.com/icon2.png"); |
| 1645 |
| 1646 IconURLSizesMap icon_url_sizes; |
| 1647 icon_url_sizes[icon_url1] = FaviconSizes(kSizesSmall); |
| 1648 icon_url_sizes[icon_url2] = FaviconSizes(kSizesSmall); |
| 1649 |
| 1650 std::vector<FaviconDataElement> elements; |
| 1651 SetFaviconDataElements(icon_url1, FaviconSizes(kSizesSmall), &elements); |
| 1652 SetFaviconsState(page_url, FAVICON, elements, icon_url_sizes); |
| 1653 |
| 1654 SetFaviconDataElements(icon_url2, FaviconSizes(kSizesSmall), &elements); |
| 1655 std::vector<unsigned char> touch_bitmap_data; |
| 1656 touch_bitmap_data.push_back('b'); |
| 1657 elements[0].bitmap_data = base::RefCountedBytes::TakeVector( |
| 1658 &touch_bitmap_data); |
| 1659 backend_->SetFavicons(page_url, TOUCH_ICON, elements, icon_url_sizes); |
| 1660 |
| 1661 // Test favicon of type FAVICON for this URL. |
| 1662 FaviconData favicon_data; |
| 1663 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, FAVICON, &favicon_data)); |
| 1664 |
| 1665 EXPECT_TRUE(favicon_data.known_icon); |
| 1666 EXPECT_FALSE(favicon_data.expired); |
| 1667 EXPECT_EQ(FAVICON, favicon_data.icon_type); |
| 1668 EXPECT_EQ(1u, favicon_data.elements.size()); |
| 1669 EXPECT_TRUE(BitmapDataEqual('a', favicon_data.elements[0].bitmap_data)); |
| 1670 EXPECT_EQ(kSmallSize, favicon_data.elements[0].pixel_size); |
| 1671 EXPECT_EQ(icon_url1, favicon_data.elements[0].icon_url); |
| 1672 |
| 1673 // Test favicon of type TOUCH_ICON for this URL. |
| 1674 FaviconData touchicon_data; |
| 1675 EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, TOUCH_ICON, |
| 1676 &touchicon_data)); |
| 1677 |
| 1678 EXPECT_TRUE(touchicon_data.known_icon); |
| 1679 EXPECT_FALSE(touchicon_data.expired); |
| 1680 EXPECT_EQ(TOUCH_ICON, touchicon_data.icon_type); |
| 1681 EXPECT_EQ(1u, touchicon_data.elements.size()); |
| 1682 EXPECT_TRUE(BitmapDataEqual('b', touchicon_data.elements[0].bitmap_data)); |
| 1683 EXPECT_EQ(kSmallSize, touchicon_data.elements[0].pixel_size); |
| 1684 EXPECT_EQ(icon_url2, touchicon_data.elements[0].icon_url); |
| 1685 } |
| 1686 |
| 1687 // Test FaviconData returned by GetFaviconsFromDB when there are no found |
| 1688 // favicons. |
| 1689 TEST_F(HistoryBackendTest, GetFaviconsFromDBEmpty) { |
| 1690 const GURL page_url("http://www.google.com/"); |
| 1691 |
| 1692 EXPECT_TRUE(DeleteFaviconsAndFaviconBitmaps(page_url, FAVICON)); |
| 1693 |
| 1694 FaviconData favicon_data; |
| 1695 EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, FAVICON, &favicon_data)); |
| 1696 EXPECT_FALSE(favicon_data.known_icon); |
| 1253 } | 1697 } |
| 1254 | 1698 |
| 1255 TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) { | 1699 TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) { |
| 1256 const GURL url("http://www.google.com/"); | 1700 const GURL url("http://www.google.com/"); |
| 1257 const GURL icon_url("http://www.google.com/icon"); | |
| 1258 const GURL same_domain_url("http://www.google.com/subdir/index.html"); | 1701 const GURL same_domain_url("http://www.google.com/subdir/index.html"); |
| 1259 const GURL foreign_domain_url("http://www.not-google.com/"); | 1702 const GURL foreign_domain_url("http://www.not-google.com/"); |
| 1260 | 1703 const GURL icon_url("http://www.google.com/icon.png"); |
| 1261 // Add a favicon | 1704 |
| 1262 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); | 1705 // Add a favicon. |
| 1263 scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); | 1706 IconURLSizesMap icon_url_sizes; |
| 1264 backend_->SetFavicon( | 1707 icon_url_sizes[icon_url] = FaviconSizes(kSizesSmall); |
| 1265 url, icon_url, bytes.get(), FAVICON); | 1708 std::vector<FaviconDataElement> elements; |
| 1266 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( | 1709 SetFaviconDataElements(icon_url, FaviconSizes(kSizesSmall), &elements); |
| 1267 url, FAVICON, NULL)); | 1710 SetFaviconsState(url, FAVICON, elements, icon_url_sizes); |
| 1268 | 1711 |
| 1269 // Validate starting state. | 1712 // Validate starting state. |
| 1270 FaviconData favicon; | 1713 FaviconData favicon_data; |
| 1271 EXPECT_TRUE(backend_->GetFaviconFromDB(url, FAVICON, &favicon)); | 1714 EXPECT_TRUE(backend_->GetFaviconsFromDB(url, FAVICON, &favicon_data)); |
| 1272 EXPECT_FALSE(backend_->GetFaviconFromDB(same_domain_url, FAVICON, &favicon)); | 1715 FaviconData favicon_data_same_domain; |
| 1273 EXPECT_FALSE(backend_->GetFaviconFromDB(foreign_domain_url, | 1716 EXPECT_FALSE(backend_->GetFaviconsFromDB(same_domain_url, FAVICON, |
| 1274 FAVICON, &favicon)); | 1717 &favicon_data_same_domain)); |
| 1718 FaviconData favicon_data_foreign_domain; |
| 1719 EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url, FAVICON, |
| 1720 &favicon_data_foreign_domain)); |
| 1275 | 1721 |
| 1276 // Same-domain cloning should work. | 1722 // Same-domain cloning should work. |
| 1277 backend_->CloneFavicon(url, same_domain_url); | 1723 backend_->CloneFavicons(url, same_domain_url); |
| 1278 EXPECT_TRUE(backend_->GetFaviconFromDB(same_domain_url, FAVICON, &favicon)); | 1724 FaviconData favicon_data_cloned_same_domain; |
| 1725 EXPECT_TRUE(backend_->GetFaviconsFromDB(same_domain_url, FAVICON, |
| 1726 &favicon_data_cloned_same_domain)); |
| 1279 | 1727 |
| 1280 // Foreign-domain cloning is forbidden. | 1728 // Foreign-domain cloning is forbidden. |
| 1281 backend_->CloneFavicon(url, foreign_domain_url); | 1729 backend_->CloneFavicons(url, foreign_domain_url); |
| 1282 EXPECT_FALSE(backend_->GetFaviconFromDB(foreign_domain_url, | 1730 FaviconData favicon_data_cloned_foreign_domain; |
| 1283 FAVICON, &favicon)); | 1731 EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url, FAVICON, |
| 1732 &favicon_data_cloned_foreign_domain)); |
| 1284 } | 1733 } |
| 1285 | 1734 |
| 1286 TEST_F(HistoryBackendTest, QueryFilteredURLs) { | 1735 TEST_F(HistoryBackendTest, QueryFilteredURLs) { |
| 1287 const char* google = "http://www.google.com/"; | 1736 const char* google = "http://www.google.com/"; |
| 1288 const char* yahoo = "http://www.yahoo.com/"; | 1737 const char* yahoo = "http://www.yahoo.com/"; |
| 1289 const char* yahoo_sports = "http://sports.yahoo.com/"; | 1738 const char* yahoo_sports = "http://sports.yahoo.com/"; |
| 1290 const char* yahoo_sports_with_article1 = | 1739 const char* yahoo_sports_with_article1 = |
| 1291 "http://sports.yahoo.com/article1.htm"; | 1740 "http://sports.yahoo.com/article1.htm"; |
| 1292 const char* yahoo_sports_with_article2 = | 1741 const char* yahoo_sports_with_article2 = |
| 1293 "http://sports.yahoo.com/article2.htm"; | 1742 "http://sports.yahoo.com/article2.htm"; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 | 2056 |
| 1608 backend_->DeleteURL(url); | 2057 backend_->DeleteURL(url); |
| 1609 backend_->AddPageNoVisitForBookmark(url, string16()); | 2058 backend_->AddPageNoVisitForBookmark(url, string16()); |
| 1610 backend_->GetURL(url, &row); | 2059 backend_->GetURL(url, &row); |
| 1611 EXPECT_EQ(url, row.url()); | 2060 EXPECT_EQ(url, row.url()); |
| 1612 EXPECT_EQ(UTF8ToUTF16(url.spec()), row.title()); | 2061 EXPECT_EQ(UTF8ToUTF16(url.spec()), row.title()); |
| 1613 EXPECT_EQ(0, row.visit_count()); | 2062 EXPECT_EQ(0, row.visit_count()); |
| 1614 } | 2063 } |
| 1615 | 2064 |
| 1616 } // namespace history | 2065 } // namespace history |
| OLD | NEW |