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

Unified Diff: chrome/browser/history/top_sites_unittest.cc

Issue 2832091: Unpin deleted URLs + better deleting algorithm. (Closed)
Patch Set: After review. Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/top_sites.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/top_sites_unittest.cc
diff --git a/chrome/browser/history/top_sites_unittest.cc b/chrome/browser/history/top_sites_unittest.cc
index c07c6fd9db5975cd43b14c08f5dae97f67fe0abe..2977e62675a9a7a38739be914ad06d4a2ea9a41e 100644
--- a/chrome/browser/history/top_sites_unittest.cc
+++ b/chrome/browser/history/top_sites_unittest.cc
@@ -790,6 +790,80 @@ TEST_F(TopSitesTest, DeleteNotifications) {
EXPECT_EQ(themes_url(), urls()[1].url);
}
+TEST_F(TopSitesTest, PinnedURLsDeleted) {
+ ChromeThread db_loop(ChromeThread::DB, MessageLoop::current());
+ GURL google1_url("http://google.com");
+ GURL google2_url("http://google.com/redirect");
+ GURL google3_url("http://www.google.com");
+ string16 google_title(ASCIIToUTF16("Google"));
+ GURL news_url("http://news.google.com");
+ string16 news_title(ASCIIToUTF16("Google News"));
+
+ MockHistoryServiceImpl hs;
+
+ top_sites().Init(file_name());
+
+ hs.AppendMockPage(google1_url, google_title);
+ hs.AppendMockPage(news_url, news_title);
+ top_sites().SetMockHistoryService(&hs);
+
+ top_sites().StartQueryForMostVisited();
+ MessageLoop::current()->RunAllPending();
+ top_sites().GetMostVisitedURLs(
+ consumer(),
+ NewCallback(static_cast<TopSitesTest*>(this),
+ &TopSitesTest::OnTopSitesAvailable));
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(1u, number_of_callbacks());
+ // 2 extra prepopulated URLs.
+ ASSERT_EQ(4u, urls().size());
+
+ top_sites().AddPinnedURL(news_url, 3);
+ EXPECT_TRUE(top_sites().IsURLPinned(news_url));
+
+ hs.RemoveMostVisitedURL();
+ history::URLsDeletedDetails history_details;
+ history_details.all_history = false;
+ history_details.urls.insert(news_url);
+ Details<URLsDeletedDetails> details(&history_details);
+ top_sites().Observe(NotificationType::HISTORY_URLS_DELETED,
+ Source<Profile> (&profile()),
+ details);
+ MessageLoop::current()->RunAllPending();
+ top_sites().GetMostVisitedURLs(
+ consumer(),
+ NewCallback(static_cast<TopSitesTest*>(this),
+ &TopSitesTest::OnTopSitesAvailable));
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(2u, number_of_callbacks());
+ ASSERT_EQ(3u, urls().size());
+ EXPECT_FALSE(top_sites().IsURLPinned(news_url));
+
+ hs.RemoveMostVisitedURL();
+ history_details.all_history = true;
+ details = Details<HistoryDetails>(&history_details);
+ top_sites().Observe(NotificationType::HISTORY_URLS_DELETED,
+ Source<Profile> (&profile()),
+ details);
+ MessageLoop::current()->RunAllPending();
+ top_sites().GetMostVisitedURLs(
+ consumer(),
+ NewCallback(static_cast<TopSitesTest*>(this),
+ &TopSitesTest::OnTopSitesAvailable));
+ ASSERT_EQ(2u, urls().size());
+ MessageLoop::current()->RunAllPending();
+
+ top_sites().StartQueryForMostVisited();
+ MessageLoop::current()->RunAllPending();
+ top_sites().GetMostVisitedURLs(
+ consumer(),
+ NewCallback(static_cast<TopSitesTest*>(this),
+ &TopSitesTest::OnTopSitesAvailable));
+ ASSERT_EQ(2u, urls().size());
+ EXPECT_EQ(welcome_url(), urls()[0].url);
+ EXPECT_EQ(themes_url(), urls()[1].url);
+}
+
TEST_F(TopSitesTest, GetUpdateDelay) {
top_sites().last_num_urls_changed_ = 0;
EXPECT_EQ(30, top_sites().GetUpdateDelay().InSeconds());
« no previous file with comments | « chrome/browser/history/top_sites.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698