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

Unified Diff: chrome/browser/webdata/web_database_migration_unittest.cc

Issue 10696127: Force WebDatabase version to max(version, compatible version) before migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fix Created 8 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
Index: chrome/browser/webdata/web_database_migration_unittest.cc
diff --git a/chrome/browser/webdata/web_database_migration_unittest.cc b/chrome/browser/webdata/web_database_migration_unittest.cc
index 1744099c1249b02a669865e4aec999d82f3b88db..513cfa735c09430bb1660b278b217135918dcea2 100644
--- a/chrome/browser/webdata/web_database_migration_unittest.cc
+++ b/chrome/browser/webdata/web_database_migration_unittest.cc
@@ -2171,3 +2171,41 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion45InvalidToCurrent) {
EXPECT_FALSE(connection.DoesTableExist("old_web_intents_defaults"));
}
}
+
+// Check that current version is forced to compatible version before migration,
+// if the former is smaller.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion45CompatibleToCurrent) {
+ ASSERT_NO_FATAL_FAILURE(
+ LoadDatabase(FILE_PATH_LITERAL("version_45_compatible.sql")));
+
+ // Verify pre-conditions. These are expectations for version 45 of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ sql::MetaTable meta_table;
+ // Database is actually version 45 but the version field states 40.
+ ASSERT_TRUE(meta_table.Init(&connection, 40, 45));
+ }
+
+ // Load the database via the WebDatabase class and migrate the database to
+ // the current version.
+ {
+ WebDatabase db;
+ ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath()));
+ }
+
+ // Verify post-conditions. These are expectations for current version of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ // Check version.
+ EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
+ EXPECT_LE(45, VersionFromConnection(&connection));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698