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

Unified Diff: components/webdata/common/web_database_migration_unittest.cc

Issue 212873003: Store the language code for the address in autofill profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 6 years, 9 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: 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 0d0c487407001b75497d0fad519ccf548b417cbd..26563b22c58b5dc50311ec58fcc3879d03b5ba51 100644
--- a/components/webdata/common/web_database_migration_unittest.cc
+++ b/components/webdata/common/web_database_migration_unittest.cc
@@ -248,7 +248,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 55;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 56;
void WebDatabaseMigrationTest::LoadDatabase(
const base::FilePath::StringType& file) {
@@ -2580,3 +2580,66 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion54ToCurrent) {
ASSERT_FALSE(s.Step());
}
}
+
+// Tests that migrating from version 55 to version 56 adds the language_code
+// column to autofill_profiles table.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion55ToCurrent) {
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_55.sql")));
+
+ // Verify pre-conditions. These are expectations for version 55 of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ EXPECT_FALSE(
+ connection.DoesColumnExist("autofill_profiles", "language_code"));
+ }
+
+ 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.
+ EXPECT_TRUE(
+ connection.DoesColumnExist("autofill_profiles", "language_code"));
+
+ // Data should have been preserved. Language code should have been set to
+ // empty string.
+ sql::Statement s_profiles(
+ connection.GetUniqueStatement(
+ "SELECT guid, company_name, street_address, dependent_locality,"
+ " city, state, zipcode, sorting_code, country_code, language_code,"
+ " date_modified, origin "
+ "FROM autofill_profiles"));
+
+ ASSERT_TRUE(s_profiles.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000001",
+ s_profiles.ColumnString(0));
+ EXPECT_EQ(ASCIIToUTF16("Google Inc"), s_profiles.ColumnString16(1));
+ EXPECT_EQ(ASCIIToUTF16("340 Main St"),
+ s_profiles.ColumnString16(2));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(3));
+ EXPECT_EQ(ASCIIToUTF16("Los Angeles"), s_profiles.ColumnString16(4));
+ EXPECT_EQ(ASCIIToUTF16("CA"), s_profiles.ColumnString16(5));
+ EXPECT_EQ(ASCIIToUTF16("90291"), s_profiles.ColumnString16(6));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(7));
+ EXPECT_EQ(ASCIIToUTF16("US"), s_profiles.ColumnString16(8));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(9));
Ilya Sherman 2014/03/29 01:24:42 Is the datatype string16 or std::string?
please use gerrit instead 2014/04/02 21:54:52 std::string. Fixed.
+ EXPECT_EQ(1395948829, s_profiles.ColumnInt(10));
+ EXPECT_EQ(ASCIIToUTF16("Chrome settings"), s_profiles.ColumnString16(11));
+
+ // No more entries expected.
+ ASSERT_FALSE(s_profiles.Step());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698