Chromium Code Reviews| 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 513cfa735c09430bb1660b278b217135918dcea2..2d340989d60f137e0112bc8c0de7530a73c80a67 100644 |
| --- a/chrome/browser/webdata/web_database_migration_unittest.cc |
| +++ b/chrome/browser/webdata/web_database_migration_unittest.cc |
| @@ -195,7 +195,7 @@ class WebDatabaseMigrationTest : public testing::Test { |
| DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); |
| }; |
| -const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 46; |
| +const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 47; |
| void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) { |
| std::string contents; |
| @@ -2209,3 +2209,49 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion45CompatibleToCurrent) { |
| EXPECT_LE(45, VersionFromConnection(&connection)); |
| } |
| } |
| + |
| +// Check that current version is forced to compatible version before migration, |
| +// if the former is smaller. |
|
Peter Kasting
2012/10/02 21:47:59
This comment is wrong
beaudoin
2012/10/03 22:46:52
Done.
Peter Kasting
2012/10/04 19:32:43
You fixed the wrong comment. The one that used to
beaudoin
2012/10/04 23:10:44
Note to self: Next time go to bed instead of tryin
|
| +TEST_F(WebDatabaseMigrationTest, MigrateVersion46ToCurrent) { |
| + ASSERT_NO_FATAL_FAILURE( |
| + LoadDatabase(FILE_PATH_LITERAL("version_46.sql"))); |
| + |
| + // Verify pre-conditions. These are expectations for version 46 of the |
| + // database. |
| + { |
| + sql::Connection connection; |
| + ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| + ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
| + |
| + sql::MetaTable meta_table; |
| + ASSERT_TRUE(meta_table.Init(&connection, 46, 46)); |
| + |
| + ASSERT_FALSE(connection.DoesColumnExist("keywords", "alternate_urls")); |
| + ASSERT_FALSE(connection.DoesColumnExist("keywords_backup", |
| + "alternate_urls")); |
| + } |
| + |
| + // 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())); |
| + ASSERT_FALSE(db.GetKeywordTable()->DidDefaultSearchProviderChange()); |
| + } |
| + |
| + // 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)); |
| + |
| + // A new column should have been created. |
| + EXPECT_TRUE(connection.DoesColumnExist("keywords", "alternate_urls")); |
| + ASSERT_TRUE(connection.DoesColumnExist("keywords_backup", |
| + "alternate_urls")); |
| + } |
| +} |