| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 CancelableRequestConsumer consumer_; | 107 CancelableRequestConsumer consumer_; |
| 108 MostVisitedURLList urls_; | 108 MostVisitedURLList urls_; |
| 109 int number_of_callbacks_; | 109 int number_of_callbacks_; |
| 110 bool waiting_; | 110 bool waiting_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(TopSitesQuerier); | 112 DISALLOW_COPY_AND_ASSIGN(TopSitesQuerier); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 // Extracts the data from |t1| into a SkBitmap. This is intended for usage of | 115 // Extracts the data from |t1| into a SkBitmap. This is intended for usage of |
| 116 // thumbnail data, which is stored as jpgs. | 116 // thumbnail data, which is stored as jpgs. |
| 117 SkBitmap ExtractThumbnail(const RefCountedMemory& t1) { | 117 SkBitmap ExtractThumbnail(const base::RefCountedMemory& t1) { |
| 118 scoped_ptr<SkBitmap> image(gfx::JPEGCodec::Decode(t1.front(), | 118 scoped_ptr<SkBitmap> image(gfx::JPEGCodec::Decode(t1.front(), |
| 119 t1.size())); | 119 t1.size())); |
| 120 return image.get() ? *image : SkBitmap(); | 120 return image.get() ? *image : SkBitmap(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Returns true if t1 and t2 contain the same data. | 123 // Returns true if t1 and t2 contain the same data. |
| 124 bool ThumbnailsAreEqual(RefCountedMemory* t1, RefCountedMemory* t2) { | 124 bool ThumbnailsAreEqual(base::RefCountedMemory* t1, |
| 125 base::RefCountedMemory* t2) { |
| 125 if (!t1 || !t2) | 126 if (!t1 || !t2) |
| 126 return false; | 127 return false; |
| 127 if (t1->size() != t2->size()) | 128 if (t1->size() != t2->size()) |
| 128 return false; | 129 return false; |
| 129 return !memcmp(t1->front(), t2->front(), t1->size()); | 130 return !memcmp(t1->front(), t2->front(), t1->size()); |
| 130 } | 131 } |
| 131 | 132 |
| 132 } // namespace | 133 } // namespace |
| 133 | 134 |
| 134 class TopSitesTest : public HistoryUnitTestBase { | 135 class TopSitesTest : public HistoryUnitTestBase { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 151 profile_.reset(); | 152 profile_.reset(); |
| 152 } | 153 } |
| 153 | 154 |
| 154 // Returns true if history and top sites should be created in SetUp. | 155 // Returns true if history and top sites should be created in SetUp. |
| 155 virtual bool CreateHistoryAndTopSites() { | 156 virtual bool CreateHistoryAndTopSites() { |
| 156 return true; | 157 return true; |
| 157 } | 158 } |
| 158 | 159 |
| 159 // Gets the thumbnail for |url| from TopSites. | 160 // Gets the thumbnail for |url| from TopSites. |
| 160 SkBitmap GetThumbnail(const GURL& url) { | 161 SkBitmap GetThumbnail(const GURL& url) { |
| 161 scoped_refptr<RefCountedMemory> data; | 162 scoped_refptr<base::RefCountedMemory> data; |
| 162 return top_sites()->GetPageThumbnail(url, &data) ? | 163 return top_sites()->GetPageThumbnail(url, &data) ? |
| 163 ExtractThumbnail(*data.get()) : SkBitmap(); | 164 ExtractThumbnail(*data.get()) : SkBitmap(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 // Creates a bitmap of the specified color. Caller takes ownership. | 167 // Creates a bitmap of the specified color. Caller takes ownership. |
| 167 gfx::Image CreateBitmap(SkColor color) { | 168 gfx::Image CreateBitmap(SkColor color) { |
| 168 SkBitmap* thumbnail = new SkBitmap; | 169 SkBitmap* thumbnail = new SkBitmap; |
| 169 thumbnail->setConfig(SkBitmap::kARGB_8888_Config, 4, 4); | 170 thumbnail->setConfig(SkBitmap::kARGB_8888_Config, 4, 4); |
| 170 thumbnail->allocPixels(); | 171 thumbnail->allocPixels(); |
| 171 thumbnail->eraseColor(color); | 172 thumbnail->eraseColor(color); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 redirects, history::SOURCE_BROWSED, false); | 265 redirects, history::SOURCE_BROWSED, false); |
| 265 history_service()->SetPageTitle(url, title); | 266 history_service()->SetPageTitle(url, title); |
| 266 } | 267 } |
| 267 | 268 |
| 268 // Delets a url. | 269 // Delets a url. |
| 269 void DeleteURL(const GURL& url) { | 270 void DeleteURL(const GURL& url) { |
| 270 history_service()->DeleteURL(url); | 271 history_service()->DeleteURL(url); |
| 271 } | 272 } |
| 272 | 273 |
| 273 // Returns true if the thumbnail equals the specified bytes. | 274 // Returns true if the thumbnail equals the specified bytes. |
| 274 bool ThumbnailEqualsBytes(const gfx::Image& image, RefCountedMemory* bytes) { | 275 bool ThumbnailEqualsBytes(const gfx::Image& image, |
| 276 base::RefCountedMemory* bytes) { |
| 275 scoped_refptr<base::RefCountedBytes> encoded_image; | 277 scoped_refptr<base::RefCountedBytes> encoded_image; |
| 276 gfx::Image copy(image); // EncodeBitmap() doesn't accept const images. | 278 gfx::Image copy(image); // EncodeBitmap() doesn't accept const images. |
| 277 TopSites::EncodeBitmap(©, &encoded_image); | 279 TopSites::EncodeBitmap(©, &encoded_image); |
| 278 return ThumbnailsAreEqual(encoded_image, bytes); | 280 return ThumbnailsAreEqual(encoded_image, bytes); |
| 279 } | 281 } |
| 280 | 282 |
| 281 // Recreates top sites. This forces top sites to reread from the db. | 283 // Recreates top sites. This forces top sites to reread from the db. |
| 282 void RecreateTopSitesAndBlock() { | 284 void RecreateTopSitesAndBlock() { |
| 283 // Recreate TopSites and wait for it to load. | 285 // Recreate TopSites and wait for it to load. |
| 284 profile()->CreateTopSites(); | 286 profile()->CreateTopSites(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 534 |
| 533 base::Time now = base::Time::Now(); | 535 base::Time now = base::Time::Now(); |
| 534 ThumbnailScore low_score(1.0, true, true, now); | 536 ThumbnailScore low_score(1.0, true, true, now); |
| 535 ThumbnailScore medium_score(0.5, true, true, now); | 537 ThumbnailScore medium_score(0.5, true, true, now); |
| 536 ThumbnailScore high_score(0.0, true, true, now); | 538 ThumbnailScore high_score(0.0, true, true, now); |
| 537 | 539 |
| 538 // Set the thumbnail. | 540 // Set the thumbnail. |
| 539 EXPECT_TRUE(top_sites()->SetPageThumbnail(url, &thumbnail, medium_score)); | 541 EXPECT_TRUE(top_sites()->SetPageThumbnail(url, &thumbnail, medium_score)); |
| 540 | 542 |
| 541 // Make sure the thumbnail was actually set. | 543 // Make sure the thumbnail was actually set. |
| 542 scoped_refptr<RefCountedMemory> result; | 544 scoped_refptr<base::RefCountedMemory> result; |
| 543 EXPECT_TRUE(top_sites()->GetPageThumbnail(url, &result)); | 545 EXPECT_TRUE(top_sites()->GetPageThumbnail(url, &result)); |
| 544 EXPECT_TRUE(ThumbnailEqualsBytes(thumbnail, result.get())); | 546 EXPECT_TRUE(ThumbnailEqualsBytes(thumbnail, result.get())); |
| 545 | 547 |
| 546 // Reset the thumbnails and make sure we don't get it back. | 548 // Reset the thumbnails and make sure we don't get it back. |
| 547 SetTopSites(MostVisitedURLList()); | 549 SetTopSites(MostVisitedURLList()); |
| 548 RefreshTopSitesAndRecreate(); | 550 RefreshTopSitesAndRecreate(); |
| 549 EXPECT_FALSE(top_sites()->GetPageThumbnail(url, &result)); | 551 EXPECT_FALSE(top_sites()->GetPageThumbnail(url, &result)); |
| 550 } | 552 } |
| 551 | 553 |
| 552 // Tests GetPageThumbnail. | 554 // Tests GetPageThumbnail. |
| 553 TEST_F(TopSitesTest, GetPageThumbnail) { | 555 TEST_F(TopSitesTest, GetPageThumbnail) { |
| 554 MostVisitedURLList url_list; | 556 MostVisitedURLList url_list; |
| 555 MostVisitedURL url1; | 557 MostVisitedURL url1; |
| 556 url1.url = GURL("http://asdf.com"); | 558 url1.url = GURL("http://asdf.com"); |
| 557 url1.redirects.push_back(url1.url); | 559 url1.redirects.push_back(url1.url); |
| 558 url_list.push_back(url1); | 560 url_list.push_back(url1); |
| 559 | 561 |
| 560 MostVisitedURL url2; | 562 MostVisitedURL url2; |
| 561 url2.url = GURL("http://gmail.com"); | 563 url2.url = GURL("http://gmail.com"); |
| 562 url2.redirects.push_back(url2.url); | 564 url2.redirects.push_back(url2.url); |
| 563 url2.redirects.push_back(GURL("http://mail.google.com")); | 565 url2.redirects.push_back(GURL("http://mail.google.com")); |
| 564 url_list.push_back(url2); | 566 url_list.push_back(url2); |
| 565 | 567 |
| 566 SetTopSites(url_list); | 568 SetTopSites(url_list); |
| 567 | 569 |
| 568 // Create a dummy thumbnail. | 570 // Create a dummy thumbnail. |
| 569 gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE)); | 571 gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE)); |
| 570 ThumbnailScore score(0.5, true, true, base::Time::Now()); | 572 ThumbnailScore score(0.5, true, true, base::Time::Now()); |
| 571 | 573 |
| 572 scoped_refptr<RefCountedMemory> result; | 574 scoped_refptr<base::RefCountedMemory> result; |
| 573 EXPECT_TRUE(top_sites()->SetPageThumbnail(url1.url, &thumbnail, score)); | 575 EXPECT_TRUE(top_sites()->SetPageThumbnail(url1.url, &thumbnail, score)); |
| 574 EXPECT_TRUE(top_sites()->GetPageThumbnail(url1.url, &result)); | 576 EXPECT_TRUE(top_sites()->GetPageThumbnail(url1.url, &result)); |
| 575 | 577 |
| 576 EXPECT_TRUE(top_sites()->SetPageThumbnail(GURL("http://gmail.com"), | 578 EXPECT_TRUE(top_sites()->SetPageThumbnail(GURL("http://gmail.com"), |
| 577 &thumbnail, score)); | 579 &thumbnail, score)); |
| 578 EXPECT_TRUE(top_sites()->GetPageThumbnail(GURL("http://gmail.com"), | 580 EXPECT_TRUE(top_sites()->GetPageThumbnail(GURL("http://gmail.com"), |
| 579 &result)); | 581 &result)); |
| 580 // Get a thumbnail via a redirect. | 582 // Get a thumbnail via a redirect. |
| 581 EXPECT_TRUE(top_sites()->GetPageThumbnail(GURL("http://mail.google.com"), | 583 EXPECT_TRUE(top_sites()->GetPageThumbnail(GURL("http://mail.google.com"), |
| 582 &result)); | 584 &result)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 RecreateTopSitesAndBlock(); | 638 RecreateTopSitesAndBlock(); |
| 637 | 639 |
| 638 { | 640 { |
| 639 TopSitesQuerier querier; | 641 TopSitesQuerier querier; |
| 640 querier.QueryTopSites(top_sites(), false); | 642 querier.QueryTopSites(top_sites(), false); |
| 641 ASSERT_EQ(1u + GetPrepopulatePages().size(), querier.urls().size()); | 643 ASSERT_EQ(1u + GetPrepopulatePages().size(), querier.urls().size()); |
| 642 EXPECT_EQ(asdf_url, querier.urls()[0].url); | 644 EXPECT_EQ(asdf_url, querier.urls()[0].url); |
| 643 EXPECT_EQ(asdf_title, querier.urls()[0].title); | 645 EXPECT_EQ(asdf_title, querier.urls()[0].title); |
| 644 ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 1)); | 646 ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 1)); |
| 645 | 647 |
| 646 scoped_refptr<RefCountedMemory> read_data; | 648 scoped_refptr<base::RefCountedMemory> read_data; |
| 647 EXPECT_TRUE(top_sites()->GetPageThumbnail(asdf_url, &read_data)); | 649 EXPECT_TRUE(top_sites()->GetPageThumbnail(asdf_url, &read_data)); |
| 648 EXPECT_TRUE(ThumbnailEqualsBytes(tmp_bitmap, read_data.get())); | 650 EXPECT_TRUE(ThumbnailEqualsBytes(tmp_bitmap, read_data.get())); |
| 649 } | 651 } |
| 650 | 652 |
| 651 MostVisitedURL url2; | 653 MostVisitedURL url2; |
| 652 url2.url = google_url; | 654 url2.url = google_url; |
| 653 url2.title = google_title; | 655 url2.title = google_title; |
| 654 url2.redirects.push_back(url2.url); | 656 url2.redirects.push_back(url2.url); |
| 655 | 657 |
| 656 AddPageToHistory(url2.url, url2.title); | 658 AddPageToHistory(url2.url, url2.title); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 | 703 |
| 702 { | 704 { |
| 703 TopSitesQuerier querier; | 705 TopSitesQuerier querier; |
| 704 querier.QueryTopSites(top_sites(), false); | 706 querier.QueryTopSites(top_sites(), false); |
| 705 | 707 |
| 706 ASSERT_EQ(1u + GetPrepopulatePages().size(), querier.urls().size()); | 708 ASSERT_EQ(1u + GetPrepopulatePages().size(), querier.urls().size()); |
| 707 EXPECT_EQ(asdf_url, querier.urls()[0].url); | 709 EXPECT_EQ(asdf_url, querier.urls()[0].url); |
| 708 EXPECT_EQ(asdf_title, querier.urls()[0].title); | 710 EXPECT_EQ(asdf_title, querier.urls()[0].title); |
| 709 ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 1)); | 711 ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 1)); |
| 710 | 712 |
| 711 scoped_refptr<RefCountedMemory> read_data; | 713 scoped_refptr<base::RefCountedMemory> read_data; |
| 712 EXPECT_TRUE(top_sites()->GetPageThumbnail(asdf_url, &read_data)); | 714 EXPECT_TRUE(top_sites()->GetPageThumbnail(asdf_url, &read_data)); |
| 713 EXPECT_TRUE(ThumbnailEqualsBytes(asdf_thumbnail, read_data.get())); | 715 EXPECT_TRUE(ThumbnailEqualsBytes(asdf_thumbnail, read_data.get())); |
| 714 } | 716 } |
| 715 | 717 |
| 716 MostVisitedURL url2; | 718 MostVisitedURL url2; |
| 717 url2.url = google3_url; | 719 url2.url = google3_url; |
| 718 url2.title = google_title; | 720 url2.title = google_title; |
| 719 url2.redirects.push_back(google1_url); | 721 url2.redirects.push_back(google1_url); |
| 720 url2.redirects.push_back(google2_url); | 722 url2.redirects.push_back(google2_url); |
| 721 url2.redirects.push_back(google3_url); | 723 url2.redirects.push_back(google3_url); |
| 722 | 724 |
| 723 AddPageToHistory(google3_url, url2.title, url2.redirects, | 725 AddPageToHistory(google3_url, url2.title, url2.redirects, |
| 724 add_time - base::TimeDelta::FromMinutes(1)); | 726 add_time - base::TimeDelta::FromMinutes(1)); |
| 725 // Add google twice so that it becomes the first visited site. | 727 // Add google twice so that it becomes the first visited site. |
| 726 AddPageToHistory(google3_url, url2.title, url2.redirects, | 728 AddPageToHistory(google3_url, url2.title, url2.redirects, |
| 727 add_time - base::TimeDelta::FromMinutes(2)); | 729 add_time - base::TimeDelta::FromMinutes(2)); |
| 728 | 730 |
| 729 gfx::Image google_thumbnail(CreateBitmap(SK_ColorBLUE)); | 731 gfx::Image google_thumbnail(CreateBitmap(SK_ColorBLUE)); |
| 730 ASSERT_TRUE(top_sites()->SetPageThumbnail( | 732 ASSERT_TRUE(top_sites()->SetPageThumbnail( |
| 731 url2.url, &google_thumbnail, ThumbnailScore())); | 733 url2.url, &google_thumbnail, ThumbnailScore())); |
| 732 | 734 |
| 733 RefreshTopSitesAndRecreate(); | 735 RefreshTopSitesAndRecreate(); |
| 734 | 736 |
| 735 { | 737 { |
| 736 scoped_refptr<RefCountedMemory> read_data; | 738 scoped_refptr<base::RefCountedMemory> read_data; |
| 737 TopSitesQuerier querier; | 739 TopSitesQuerier querier; |
| 738 querier.QueryTopSites(top_sites(), false); | 740 querier.QueryTopSites(top_sites(), false); |
| 739 | 741 |
| 740 ASSERT_EQ(2u + GetPrepopulatePages().size(), querier.urls().size()); | 742 ASSERT_EQ(2u + GetPrepopulatePages().size(), querier.urls().size()); |
| 741 EXPECT_EQ(google1_url, querier.urls()[0].url); | 743 EXPECT_EQ(google1_url, querier.urls()[0].url); |
| 742 EXPECT_EQ(google_title, querier.urls()[0].title); | 744 EXPECT_EQ(google_title, querier.urls()[0].title); |
| 743 ASSERT_EQ(3u, querier.urls()[0].redirects.size()); | 745 ASSERT_EQ(3u, querier.urls()[0].redirects.size()); |
| 744 EXPECT_TRUE(top_sites()->GetPageThumbnail(google3_url, &read_data)); | 746 EXPECT_TRUE(top_sites()->GetPageThumbnail(google3_url, &read_data)); |
| 745 EXPECT_TRUE(ThumbnailEqualsBytes(google_thumbnail, read_data.get())); | 747 EXPECT_TRUE(ThumbnailEqualsBytes(google_thumbnail, read_data.get())); |
| 746 | 748 |
| 747 EXPECT_EQ(asdf_url, querier.urls()[1].url); | 749 EXPECT_EQ(asdf_url, querier.urls()[1].url); |
| 748 EXPECT_EQ(asdf_title, querier.urls()[1].title); | 750 EXPECT_EQ(asdf_title, querier.urls()[1].title); |
| 749 ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 2)); | 751 ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 2)); |
| 750 } | 752 } |
| 751 | 753 |
| 752 gfx::Image weewar_bitmap(CreateBitmap(SK_ColorYELLOW)); | 754 gfx::Image weewar_bitmap(CreateBitmap(SK_ColorYELLOW)); |
| 753 | 755 |
| 754 base::Time thumbnail_time(base::Time::Now()); | 756 base::Time thumbnail_time(base::Time::Now()); |
| 755 ThumbnailScore low_score(1.0, true, true, thumbnail_time); | 757 ThumbnailScore low_score(1.0, true, true, thumbnail_time); |
| 756 ThumbnailScore medium_score(0.5, true, true, thumbnail_time); | 758 ThumbnailScore medium_score(0.5, true, true, thumbnail_time); |
| 757 ThumbnailScore high_score(0.0, true, true, thumbnail_time); | 759 ThumbnailScore high_score(0.0, true, true, thumbnail_time); |
| 758 | 760 |
| 759 // 1. Set to weewar. (Writes the thumbnail to the DB.) | 761 // 1. Set to weewar. (Writes the thumbnail to the DB.) |
| 760 EXPECT_TRUE(top_sites()->SetPageThumbnail(google3_url, | 762 EXPECT_TRUE(top_sites()->SetPageThumbnail(google3_url, |
| 761 &weewar_bitmap, | 763 &weewar_bitmap, |
| 762 medium_score)); | 764 medium_score)); |
| 763 RefreshTopSitesAndRecreate(); | 765 RefreshTopSitesAndRecreate(); |
| 764 { | 766 { |
| 765 scoped_refptr<RefCountedMemory> read_data; | 767 scoped_refptr<base::RefCountedMemory> read_data; |
| 766 EXPECT_TRUE(top_sites()->GetPageThumbnail(google3_url, &read_data)); | 768 EXPECT_TRUE(top_sites()->GetPageThumbnail(google3_url, &read_data)); |
| 767 EXPECT_TRUE(ThumbnailEqualsBytes(weewar_bitmap, read_data.get())); | 769 EXPECT_TRUE(ThumbnailEqualsBytes(weewar_bitmap, read_data.get())); |
| 768 } | 770 } |
| 769 | 771 |
| 770 gfx::Image green_bitmap(CreateBitmap(SK_ColorGREEN)); | 772 gfx::Image green_bitmap(CreateBitmap(SK_ColorGREEN)); |
| 771 | 773 |
| 772 // 2. Set to google - low score. | 774 // 2. Set to google - low score. |
| 773 EXPECT_FALSE(top_sites()->SetPageThumbnail(google3_url, | 775 EXPECT_FALSE(top_sites()->SetPageThumbnail(google3_url, |
| 774 &green_bitmap, | 776 &green_bitmap, |
| 775 low_score)); | 777 low_score)); |
| 776 | 778 |
| 777 // 3. Set to google - high score. | 779 // 3. Set to google - high score. |
| 778 EXPECT_TRUE(top_sites()->SetPageThumbnail(google1_url, | 780 EXPECT_TRUE(top_sites()->SetPageThumbnail(google1_url, |
| 779 &green_bitmap, | 781 &green_bitmap, |
| 780 high_score)); | 782 high_score)); |
| 781 | 783 |
| 782 // Check that the thumbnail was updated. | 784 // Check that the thumbnail was updated. |
| 783 RefreshTopSitesAndRecreate(); | 785 RefreshTopSitesAndRecreate(); |
| 784 { | 786 { |
| 785 scoped_refptr<RefCountedMemory> read_data; | 787 scoped_refptr<base::RefCountedMemory> read_data; |
| 786 EXPECT_TRUE(top_sites()->GetPageThumbnail(google3_url, &read_data)); | 788 EXPECT_TRUE(top_sites()->GetPageThumbnail(google3_url, &read_data)); |
| 787 EXPECT_FALSE(ThumbnailEqualsBytes(weewar_bitmap, read_data.get())); | 789 EXPECT_FALSE(ThumbnailEqualsBytes(weewar_bitmap, read_data.get())); |
| 788 EXPECT_TRUE(ThumbnailEqualsBytes(green_bitmap, read_data.get())); | 790 EXPECT_TRUE(ThumbnailEqualsBytes(green_bitmap, read_data.get())); |
| 789 } | 791 } |
| 790 } | 792 } |
| 791 | 793 |
| 792 TEST_F(TopSitesTest, DeleteNotifications) { | 794 TEST_F(TopSitesTest, DeleteNotifications) { |
| 793 GURL google1_url("http://google.com"); | 795 GURL google1_url("http://google.com"); |
| 794 GURL google2_url("http://google.com/redirect"); | 796 GURL google2_url("http://google.com/redirect"); |
| 795 GURL google3_url("http://www.google.com"); | 797 GURL google3_url("http://www.google.com"); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 EXPECT_FALSE(top_sites()->SetPageThumbnail(invalid_url, | 1041 EXPECT_FALSE(top_sites()->SetPageThumbnail(invalid_url, |
| 1040 &thumbnail, | 1042 &thumbnail, |
| 1041 medium_score)); | 1043 medium_score)); |
| 1042 // Store thumbnails for unknown (but valid) URLs temporarily - calls | 1044 // Store thumbnails for unknown (but valid) URLs temporarily - calls |
| 1043 // AddTemporaryThumbnail. | 1045 // AddTemporaryThumbnail. |
| 1044 EXPECT_TRUE(top_sites()->SetPageThumbnail(unknown_url, | 1046 EXPECT_TRUE(top_sites()->SetPageThumbnail(unknown_url, |
| 1045 &thumbnail, | 1047 &thumbnail, |
| 1046 medium_score)); | 1048 medium_score)); |
| 1047 | 1049 |
| 1048 // We shouldn't get the thumnail back though (the url isn't in to sites yet). | 1050 // We shouldn't get the thumnail back though (the url isn't in to sites yet). |
| 1049 scoped_refptr<RefCountedMemory> out; | 1051 scoped_refptr<base::RefCountedMemory> out; |
| 1050 EXPECT_FALSE(top_sites()->GetPageThumbnail(unknown_url, &out)); | 1052 EXPECT_FALSE(top_sites()->GetPageThumbnail(unknown_url, &out)); |
| 1051 // But we should be able to get the temporary page thumbnail score. | 1053 // But we should be able to get the temporary page thumbnail score. |
| 1052 ThumbnailScore out_score; | 1054 ThumbnailScore out_score; |
| 1053 EXPECT_TRUE(top_sites()->GetTemporaryPageThumbnailScore(unknown_url, | 1055 EXPECT_TRUE(top_sites()->GetTemporaryPageThumbnailScore(unknown_url, |
| 1054 &out_score)); | 1056 &out_score)); |
| 1055 EXPECT_TRUE(medium_score.Equals(out_score)); | 1057 EXPECT_TRUE(medium_score.Equals(out_score)); |
| 1056 | 1058 |
| 1057 std::vector<MostVisitedURL> list; | 1059 std::vector<MostVisitedURL> list; |
| 1058 | 1060 |
| 1059 MostVisitedURL mv; | 1061 MostVisitedURL mv; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 ui_test_utils::WindowedNotificationObserver observer( | 1238 ui_test_utils::WindowedNotificationObserver observer( |
| 1237 chrome::NOTIFICATION_TOP_SITES_LOADED, | 1239 chrome::NOTIFICATION_TOP_SITES_LOADED, |
| 1238 content::Source<Profile>(profile())); | 1240 content::Source<Profile>(profile())); |
| 1239 profile()->CreateTopSites(); | 1241 profile()->CreateTopSites(); |
| 1240 profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)->UnloadBackend(); | 1242 profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)->UnloadBackend(); |
| 1241 profile()->BlockUntilHistoryProcessesPendingRequests(); | 1243 profile()->BlockUntilHistoryProcessesPendingRequests(); |
| 1242 observer.Wait(); | 1244 observer.Wait(); |
| 1243 } | 1245 } |
| 1244 | 1246 |
| 1245 } // namespace history | 1247 } // namespace history |
| OLD | NEW |