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 9259e8ffeb2d9c89bb145b283cf84cd7146366e9..80e5079138642831489b27db6d6f0b2a5c9d1422 100644 |
| --- a/chrome/browser/webdata/web_database_migration_unittest.cc |
| +++ b/chrome/browser/webdata/web_database_migration_unittest.cc |
| @@ -196,7 +196,7 @@ class WebDatabaseMigrationTest : public testing::Test { |
| DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); |
| }; |
| -const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 40; |
| +const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 41; |
| void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) { |
| std::string contents; |
| @@ -1506,7 +1506,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion38ToCurrent) { |
| // Tests that the backup field for the default search provider gets added to |
| // the meta table of a version 39 database. |
| TEST_F(WebDatabaseMigrationTest, MigrateVersion39ToCurrent) { |
| - // This schema is taken from a build prior to the addition of the defaul |
| + // This schema is taken from a build prior to the addition of the default |
| // search provider backup field to the meta table. |
| ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_39.sql"))); |
| @@ -1577,3 +1577,80 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion39ToCurrent) { |
| } |
| } |
| +// Tests that the backup field for the default search provider is rewritten |
| +// despite any value in the old version. |
| +TEST_F(WebDatabaseMigrationTest, MigrateVersion40ToCurrent) { |
| + // This schema is taken from a build after the addition of the default |
| + // search provider backup field to the meta table. Due to crbug.com/101815 |
| + // the signature was empty in all build between revisions 106214 and 108111. |
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_40.sql"))); |
| + |
| + // Verify pre-conditions. These are expectations for version 40 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, 40, 40)); |
| + |
| + int64 default_search_provider_id = 0; |
| + EXPECT_TRUE(meta_table.GetValue( |
| + "Default Search Provider ID", |
| + &default_search_provider_id)); |
| + |
| + int64 default_search_provider_id_backup = 0; |
| + EXPECT_TRUE(meta_table.GetValue( |
| + "Default Search Provider ID Backup", |
| + &default_search_provider_id_backup)); |
| + |
| + std::string default_search_provider_id_backup_signature; |
| + EXPECT_TRUE(meta_table.GetValue( |
| + "Default Search Provider ID Backup Signature", |
| + &default_search_provider_id_backup_signature)); |
| + EXPECT_TRUE(default_search_provider_id_backup_signature.empty()); |
| + } |
| + |
| + // 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)); |
| + |
| + sql::MetaTable meta_table; |
| + ASSERT_TRUE(meta_table.Init( |
| + &connection, |
| + kCurrentTestedVersionNumber, |
| + kCurrentTestedVersionNumber)); |
| + |
| + int64 default_search_provider_id = 0; |
| + EXPECT_TRUE(meta_table.GetValue( |
| + "Default Search Provider ID", |
| + &default_search_provider_id)); |
| + |
| + int64 default_search_provider_id_backup = 0; |
| + EXPECT_TRUE(meta_table.GetValue( |
| + "Default Search Provider ID Backup", |
| + &default_search_provider_id_backup)); |
| + EXPECT_EQ(default_search_provider_id, default_search_provider_id_backup); |
|
sky
2011/11/08 15:55:44
Can you add a EXPECT_NE(0, default_search_provider
whywhat
2011/11/08 16:20:18
Done.
|
| + |
| + std::string default_search_provider_id_backup_signature; |
| + EXPECT_TRUE(meta_table.GetValue( |
| + "Default Search Provider ID Backup Signature", |
| + &default_search_provider_id_backup_signature)); |
| + EXPECT_FALSE(default_search_provider_id_backup_signature.empty()); |
| + } |
| +} |
| + |