summaryrefslogtreecommitdiffstats
path: root/chrome/browser/webdata/web_database_unittest.cc
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 23:15:42 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 23:15:42 +0000
commitcea467f6e990d9990209a97ce3e896cb5ff72212 (patch)
tree569477d0332900bd572f73e369470d13df1b2f15 /chrome/browser/webdata/web_database_unittest.cc
parent81a476540d6f2e30441ce623a3ee146894c88bfd (diff)
downloadchromium_src-cea467f6e990d9990209a97ce3e896cb5ff72212.zip
chromium_src-cea467f6e990d9990209a97ce3e896cb5ff72212.tar.gz
chromium_src-cea467f6e990d9990209a97ce3e896cb5ff72212.tar.bz2
Chrome crashes on migration of Autofill data with country "UK" round 2
Migrates bad country code "UK" to good country code "GB". These bad country codes were introduced in build 686. BUG=74511 TEST=WebDatabaseMigrationTest.MigrateVersion34ToCurrent TBR=isherman@chromium.org Review URL: http://codereview.chromium.org/6606021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76648 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata/web_database_unittest.cc')
-rw-r--r--chrome/browser/webdata/web_database_unittest.cc61
1 files changed, 60 insertions, 1 deletions
diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc
index 2adae26..d9d19ae 100644
--- a/chrome/browser/webdata/web_database_unittest.cc
+++ b/chrome/browser/webdata/web_database_unittest.cc
@@ -2104,7 +2104,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 34;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 35;
void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
std::string contents;
@@ -3172,3 +3172,62 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion33ToCurrent) {
EXPECT_EQ("US", country_code);
}
}
+
+// Cleans up bad country code "UK" in favor of good country code "GB".
+TEST_F(WebDatabaseMigrationTest, MigrateVersion34ToCurrent) {
+ // Initialize the database.
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_34.sql")));
+
+ // Verify pre-conditions. These are expectations for version 34 of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+
+ EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles",
+ "country_code"));
+
+ // Check that the country_code value is the one we expect.
+ sql::Statement s(
+ connection.GetUniqueStatement("SELECT country_code "
+ "FROM autofill_profiles"));
+
+ ASSERT_TRUE(s.Step());
+ std::string country_code = s.ColumnString(0);
+ EXPECT_EQ("UK", country_code);
+
+ // Should have only one.
+ ASSERT_FALSE(s.Step());
+ }
+
+ // 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 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("GB", country_code);
+
+ // Should have only one.
+ ASSERT_FALSE(s.Step());
+ }
+}