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

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

Issue 947693002: Add use_count and use_date to unmasked server cards as well. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: internal time instead of time_t Created 5 years, 10 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
« no previous file with comments | « components/webdata/common/web_database.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 eb04c2ac3923b78946dd3eeae76ad435a617bb31..fbba5cd8d14a0d911f425c949497184fa850b789 100644
--- a/components/webdata/common/web_database_migration_unittest.cc
+++ b/components/webdata/common/web_database_migration_unittest.cc
@@ -233,9 +233,9 @@ class WebDatabaseMigrationTest : public testing::Test {
return s.ColumnInt(0);
}
- // The sql files located in "chrome/test/data/web_database" were generated by
- // launching the Chromium application prior to schema change, then using the
- // sqlite3 command-line application to dump the contents of the "Web Data"
+ // The sql files located in "components/test/data/web_database" were generated
+ // by launching the Chromium application prior to schema change, then using
+ // the sqlite3 command-line application to dump the contents of the "Web Data"
// database.
// Like this:
// > .output version_nn.sql
@@ -248,7 +248,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 61;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 62;
void WebDatabaseMigrationTest::LoadDatabase(
const base::FilePath::StringType& file) {
@@ -2810,3 +2810,78 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion59ToCurrent) {
ASSERT_TRUE(connection.DoesTableExist("server_addresses"));
}
}
+
+// Tests addition of use_count and use_date fields to autofill profiles and
+// credit cards.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion60ToCurrent) {
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_60.sql")));
+
+ // Verify pre-conditions.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ sql::MetaTable meta_table;
+ ASSERT_TRUE(meta_table.Init(&connection, 60, 60));
+
+ EXPECT_FALSE(connection.DoesColumnExist("credit_cards", "use_count"));
+ EXPECT_FALSE(connection.DoesColumnExist("credit_cards", "use_date"));
+ EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", "use_count"));
+ EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", "use_date"));
+ }
+
+ DoMigration();
+
+ // Verify post-conditions.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ // Check version.
+ EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
+
+ EXPECT_TRUE(connection.DoesColumnExist("credit_cards", "use_count"));
+ EXPECT_TRUE(connection.DoesColumnExist("credit_cards", "use_date"));
+ EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "use_count"));
+ EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "use_date"));
+ }
+}
+
+// Tests addition of use_count and use_date fields to unmasked server cards.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion61ToCurrent) {
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_61.sql")));
+
+ // Verify pre-conditions.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ sql::MetaTable meta_table;
+ ASSERT_TRUE(meta_table.Init(&connection, 61, 61));
+
+ EXPECT_FALSE(connection.DoesColumnExist("unmasked_credit_cards",
+ "use_count"));
+ EXPECT_FALSE(connection.DoesColumnExist("unmasked_credit_cards",
+ "use_date"));
+ }
+
+ DoMigration();
+
+ // Verify post-conditions.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ // Check version.
+ EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
+
+ EXPECT_TRUE(connection.DoesColumnExist("unmasked_credit_cards",
+ "use_count"));
+ EXPECT_TRUE(connection.DoesColumnExist("unmasked_credit_cards",
+ "use_date"));
+ }
+}
« no previous file with comments | « components/webdata/common/web_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698