| Index: chrome/browser/webdata/web_database_unittest.cc
|
| diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc
|
| index 0c9b758d959b3548a08adf0e3ba285926700823b..6ae10cb549fc8f1f931a5dd3528fea618d503a10 100644
|
| --- a/chrome/browser/webdata/web_database_unittest.cc
|
| +++ b/chrome/browser/webdata/web_database_unittest.cc
|
| @@ -2042,7 +2042,7 @@ class WebDatabaseMigrationTest : public testing::Test {
|
| // Like this:
|
| // > .output version_nn.sql
|
| // > .dump
|
| - void LoadDatabase(const FilePath& path);
|
| + void LoadDatabase(const FilePath::StringType& file);
|
|
|
| // Assertion testing for migrating from version 27 and 28.
|
| void MigrateVersion28Assertions();
|
| @@ -2053,11 +2053,11 @@ class WebDatabaseMigrationTest : public testing::Test {
|
| DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
|
| };
|
|
|
| -const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 32;
|
| +const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 33;
|
|
|
| -void WebDatabaseMigrationTest::LoadDatabase(const FilePath& file) {
|
| +void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
|
| std::string contents;
|
| - ASSERT_TRUE(GetWebDatabaseData(file, &contents));
|
| + ASSERT_TRUE(GetWebDatabaseData(FilePath(file), &contents));
|
|
|
| sql::Connection connection;
|
| ASSERT_TRUE(connection.Open(GetDatabasePath()));
|
| @@ -2162,8 +2162,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion22ToCurrent) {
|
| // This schema is taken from a build prior to the addition of the
|
| // |credit_card| table. Version 22 of the schema. Contrast this with the
|
| // corrupt version below.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_22.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_22.sql")));
|
|
|
| // Verify pre-conditions.
|
| {
|
| @@ -2209,7 +2208,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion22CorruptedToCurrent) {
|
| // table. Due to a bug in the migration logic the version is set incorrectly
|
| // to 22 (it should have been updated to 23 at least).
|
| ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_22_corrupt.sql"))));
|
| + LoadDatabase(FILE_PATH_LITERAL("version_22_corrupt.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for corrupt version 22 of
|
| // the database.
|
| @@ -2257,8 +2256,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion22CorruptedToCurrent) {
|
| TEST_F(WebDatabaseMigrationTest, MigrateVersion24ToCurrent) {
|
| // This schema is taken from a build prior to the addition of the |keywords|
|
| // |logo_id| column.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_24.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_24.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for version 24 of the
|
| // database.
|
| @@ -2298,8 +2296,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion24ToCurrent) {
|
| TEST_F(WebDatabaseMigrationTest, MigrateVersion25ToCurrent) {
|
| // This schema is taken from a build prior to the addition of the |keywords|
|
| // |created_by_policy| column.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_25.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_25.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for version 25 of the
|
| // database.
|
| @@ -2336,8 +2333,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion25ToCurrent) {
|
| TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringLabels) {
|
| // This schema is taken from a build prior to the change of column type for
|
| // credit_cards.billing_address from string to int.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_26.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_26.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for version 26 of the
|
| // database.
|
| @@ -2410,8 +2406,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringLabels) {
|
| TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringIDs) {
|
| // This schema is taken from a build prior to the change of column type for
|
| // credit_cards.billing_address from string to int.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_26.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_26.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for version 26 of the
|
| // database.
|
| @@ -2484,8 +2479,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringIDs) {
|
| // as the column added in 28 was nuked in 29.
|
| TEST_F(WebDatabaseMigrationTest, MigrateVersion27ToCurrent) {
|
| // Initialize the database.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_27.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_27.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for version 28 of the
|
| // database.
|
| @@ -2503,8 +2497,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion27ToCurrent) {
|
| // Makes sure instant_url is added correctly to keywords.
|
| TEST_F(WebDatabaseMigrationTest, MigrateVersion28ToCurrent) {
|
| // Initialize the database.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_28.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_28.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for version 28 of the
|
| // database.
|
| @@ -2523,8 +2516,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion28ToCurrent) {
|
| // credit_cards.
|
| TEST_F(WebDatabaseMigrationTest, MigrateVersion29ToCurrent) {
|
| // Initialize the database.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_29.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_29.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for version 29 of the
|
| // database.
|
| @@ -2589,8 +2581,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion29ToCurrent) {
|
| // Makes sure guids are added to autofill_profiles and credit_cards tables.
|
| TEST_F(WebDatabaseMigrationTest, MigrateVersion30ToCurrent) {
|
| // Initialize the database.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_30.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_30.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for version 29 of the
|
| // database.
|
| @@ -2642,8 +2633,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion30ToCurrent) {
|
| // columns.
|
| TEST_F(WebDatabaseMigrationTest, MigrateVersion31ToCurrent) {
|
| // Initialize the database.
|
| - ASSERT_NO_FATAL_FAILURE(
|
| - LoadDatabase(FilePath(FILE_PATH_LITERAL("version_31.sql"))));
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_31.sql")));
|
|
|
| // Verify pre-conditions. These are expectations for version 30 of the
|
| // database.
|
| @@ -2776,3 +2766,56 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion31ToCurrent) {
|
| EXPECT_EQ(cc_date_modified, cc_date_modified_a);
|
| }
|
| }
|
| +
|
| +// Adds a column for the autofill profile's country code.
|
| +TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
|
| + // Initialize the database.
|
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_32.sql")));
|
| +
|
| + // Verify pre-conditions. These are expectations for version 32 of the
|
| + // database.
|
| + {
|
| + sql::Connection connection;
|
| + ASSERT_TRUE(connection.Open(GetDatabasePath()));
|
| +
|
| + EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles",
|
| + "country_code"));
|
| +
|
| + // Check that the country value is the one we expect.
|
| + sql::Statement s(
|
| + connection.GetUniqueStatement("SELECT country FROM autofill_profiles"));
|
| +
|
| + ASSERT_TRUE(s.Step());
|
| + std::string country = s.ColumnString(0);
|
| + EXPECT_EQ("United States", country);
|
| + }
|
| +
|
| + // 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()));
|
| +
|
| + // Check version.
|
| + EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
|
| +
|
| + ASSERT_TRUE(connection.DoesColumnExist("autofill_profiles",
|
| + "country_code"));
|
| +
|
| + // Check that the country code is properly converted.
|
| + sql::Statement s(connection.GetUniqueStatement(
|
| + "SELECT country_code FROM autofill_profiles"));
|
| +
|
| + ASSERT_TRUE(s.Step());
|
| + std::string country_code = s.ColumnString(0);
|
| + EXPECT_EQ("US", country_code);
|
| + }
|
| +}
|
| +
|
|
|