Chromium Code Reviews| Index: components/webdata/common/web_database_migration_unittest.cc |
| diff --git a/components/webdata/common/web_database_migration_unittest.cc b/components/webdata/common/web_database_migration_unittest.cc |
| index aa3d0dd65a40023b66b282801a99afcdab169ea8..adf762ab1ff1dc2e2ee96c484a1216d65b5965ca 100644 |
| --- a/components/webdata/common/web_database_migration_unittest.cc |
| +++ b/components/webdata/common/web_database_migration_unittest.cc |
| @@ -256,7 +256,7 @@ class WebDatabaseMigrationTest : public testing::Test { |
| DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); |
| }; |
| -const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 56; |
| +const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 57; |
| void WebDatabaseMigrationTest::LoadDatabase( |
| const base::FilePath::StringType& file) { |
| @@ -2670,3 +2670,55 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion55ToCurrent) { |
| ASSERT_FALSE(s_profiles.Step()); |
| } |
| } |
| + |
| +// Tests that migrating from version 56 to version 57 adds the full_name |
| +// column to autofill_profile_names table. |
| +TEST_F(WebDatabaseMigrationTest, MigrateVersion56ToCurrent) { |
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_56.sql"))); |
| + |
| + // Verify pre-conditions. These are expectations for version 56 of the |
| + // database. |
| + { |
| + sql::Connection connection; |
| + ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| + ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
| + |
| + EXPECT_FALSE( |
| + connection.DoesColumnExist("autofill_profile_names", "full_name")); |
|
Ilya Sherman
2014/06/12 23:25:25
I'd prefer that you also verify that the table sta
Evan Stade
2014/06/14 01:17:24
Done.
|
| + } |
| + |
| + DoMigration(); |
| + |
| + // 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)); |
| + |
| + // The language_code column should have been added to autofill_profiles |
| + // table. |
|
Ilya Sherman
2014/06/12 23:25:25
nit: Please update this comment.
Evan Stade
2014/06/14 01:17:23
Done.
|
| + EXPECT_TRUE( |
| + connection.DoesColumnExist("autofill_profile_names", "full_name")); |
| + |
| + // Data should have been preserved. Full name should have been set to the |
| + // empty string. |
| + sql::Statement s_names( |
| + connection.GetUniqueStatement( |
| + "SELECT guid, first_name, middle_name, last_name, full_name " |
| + "FROM autofill_profile_names")); |
| + |
| + ASSERT_TRUE(s_names.Step()); |
| + EXPECT_EQ("B41FE6E0-B13E-2A2A-BF0B-29FCE2C3ADBD", s_names.ColumnString(0)); |
| + EXPECT_EQ(ASCIIToUTF16("Jon"), s_names.ColumnString16(1)); |
| + EXPECT_EQ(ASCIIToUTF16(""), s_names.ColumnString16(2)); |
| + EXPECT_EQ(ASCIIToUTF16("Smith"), s_names.ColumnString16(3)); |
| + EXPECT_EQ(ASCIIToUTF16(""), s_names.ColumnString16(4)); |
|
Ilya Sherman
2014/06/12 23:25:25
nit: "base::string16()" is generally preferred ove
Evan Stade
2014/06/14 01:17:23
Done.
|
| + |
| + // No more entries expected. |
| + ASSERT_FALSE(s_names.Step()); |
| + } |
| +} |