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

Unified Diff: components/history/core/browser/top_sites_database_unittest.cc

Issue 2727553006: [sql] Convert thumbnails and top-sites databases to auto-recovery. (Closed)
Patch Set: tests and review comments Created 3 years, 9 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 | « components/history/core/browser/top_sites_database.cc ('k') | sql/recovery.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/history/core/browser/top_sites_database_unittest.cc
diff --git a/components/history/core/browser/top_sites_database_unittest.cc b/components/history/core/browser/top_sites_database_unittest.cc
index 289b983040405c35b38c59c0338310823d354670..29683551742cafe2424a840d954fff43a83a7665 100644
--- a/components/history/core/browser/top_sites_database_unittest.cc
+++ b/components/history/core/browser/top_sites_database_unittest.cc
@@ -86,31 +86,15 @@ TEST_F(TopSitesDatabaseTest, Version1) {
VerifyDatabaseEmpty(db.db_.get());
}
+// Version 2 is deprecated, the resulting schema should be current,
+// with no data.
TEST_F(TopSitesDatabaseTest, Version2) {
ASSERT_TRUE(CreateDatabaseFromSQL(file_name_, "TopSites.v2.sql"));
TopSitesDatabase db;
ASSERT_TRUE(db.Init(file_name_));
-
VerifyTablesAndColumns(db.db_.get());
-
- // Basic operational check.
- MostVisitedURLList urls;
- std::map<GURL, Images> thumbnails;
- db.GetPageThumbnails(&urls, &thumbnails);
- ASSERT_EQ(3u, urls.size());
- ASSERT_EQ(3u, thumbnails.size());
- EXPECT_EQ(kUrl0, urls[0].url); // [0] because of url_rank.
- // kGoogleThumbnail includes nul terminator.
- ASSERT_EQ(sizeof(kGoogleThumbnail) - 1,
- thumbnails[urls[0].url].thumbnail->size());
- EXPECT_TRUE(!memcmp(thumbnails[urls[0].url].thumbnail->front(),
- kGoogleThumbnail, sizeof(kGoogleThumbnail) - 1));
-
- ASSERT_TRUE(db.RemoveURL(urls[1]));
- db.GetPageThumbnails(&urls, &thumbnails);
- ASSERT_EQ(2u, urls.size());
- ASSERT_EQ(2u, thumbnails.size());
+ VerifyDatabaseEmpty(db.db_.get());
}
TEST_F(TopSitesDatabaseTest, Version3) {
@@ -198,29 +182,15 @@ TEST_F(TopSitesDatabaseTest, Recovery2) {
ASSERT_TRUE(expecter.SawExpectedErrors());
}
- // Corruption should be detected and recovered during Init(). After recovery,
- // the Version2 checks should work.
+ // Corruption should be detected and recovered during Init().
{
sql::test::ScopedErrorExpecter expecter;
expecter.ExpectError(SQLITE_CORRUPT);
TopSitesDatabase db;
ASSERT_TRUE(db.Init(file_name_));
-
VerifyTablesAndColumns(db.db_.get());
-
- // Basic operational check.
- MostVisitedURLList urls;
- std::map<GURL, Images> thumbnails;
- db.GetPageThumbnails(&urls, &thumbnails);
- ASSERT_EQ(3u, urls.size());
- ASSERT_EQ(3u, thumbnails.size());
- EXPECT_EQ(kUrl0, urls[0].url); // [0] because of url_rank.
- // kGoogleThumbnail includes nul terminator.
- ASSERT_EQ(sizeof(kGoogleThumbnail) - 1,
- thumbnails[urls[0].url].thumbnail->size());
- EXPECT_TRUE(!memcmp(thumbnails[urls[0].url].thumbnail->front(),
- kGoogleThumbnail, sizeof(kGoogleThumbnail) - 1));
+ VerifyDatabaseEmpty(db.db_.get());
ASSERT_TRUE(expecter.SawExpectedErrors());
}
« no previous file with comments | « components/history/core/browser/top_sites_database.cc ('k') | sql/recovery.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698