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

Unified Diff: components/password_manager/core/browser/login_database_unittest.cc

Issue 818443004: Remove use_additional_auth column from logins table. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/password_manager/core/browser/login_database_unittest.cc
diff --git a/components/password_manager/core/browser/login_database_unittest.cc b/components/password_manager/core/browser/login_database_unittest.cc
index 67c04ab35d192811ef7e7e1bfdd2818badf34e1a..c0466365778c5e78c69a752055a65ff0de03e991 100644
--- a/components/password_manager/core/browser/login_database_unittest.cc
+++ b/components/password_manager/core/browser/login_database_unittest.cc
@@ -1132,12 +1132,11 @@ class LoginDatabaseMigrationTest : public testing::Test {
}
// Creates database of specific |version|.
- void CreateDatabase(int version) {
+ void CreateDatabase(std::string version) {
base::FilePath database_dump;
PathService::Get(base::DIR_SOURCE_ROOT, &database_dump);
- database_dump =
- database_dump.Append(database_dump_location_)
- .AppendASCII("login_db_v" + base::IntToString(version) + ".sql");
+ database_dump = database_dump.Append(database_dump_location_)
+ .AppendASCII("login_db_v" + version + ".sql");
ASSERT_TRUE(
sql::test::CreateDatabaseFromSQL(database_path_, database_dump));
}
@@ -1184,12 +1183,28 @@ class LoginDatabaseMigrationTest : public testing::Test {
// will be changed to 10, because file login_db_v10.sql doesn't exist.
// It has to be added in order to fix test.
TEST_F(LoginDatabaseMigrationTest, MigrationV1ToVCurrent) {
- for (int version = 1; version < kCurrentVersionNumber; ++version) {
+ std::vector<std::string> versions;
+ for (int version = 1; version < kCurrentVersionNumber; ++version)
+ versions.push_back(base::IntToString(version));
+ versions.push_back("9_without_use_additional_auth_field");
+
+ for (const auto& version : versions) {
CreateDatabase(version);
+ SCOPED_TRACE(testing::Message("Version = ") << version);
// Original date, in seconds since UTC epoch.
std::vector<int64_t> date_created(GetDateCreated());
- ASSERT_EQ(1402955745, date_created[0]);
- ASSERT_EQ(1402950000, date_created[1]);
+ int table_version;
+ base::StringToInt(version, &table_version);
+ // Migration to version 8 performs changes dates to the new format.
+ // So for versions less of equal to 8 create date should be in old
+ // format before migration and in new format after.
+ if (table_version <= 8) {
+ ASSERT_EQ(1402955745, date_created[0]);
+ ASSERT_EQ(1402950000, date_created[1]);
+ } else {
+ ASSERT_EQ(13047429345000000, date_created[0]);
+ ASSERT_EQ(13047423600000000, date_created[1]);
+ }
{
// Assert that the database was successfully opened and updated
@@ -1212,10 +1227,12 @@ TEST_F(LoginDatabaseMigrationTest, MigrationV1ToVCurrent) {
std::vector<int64_t> new_date_created(GetDateCreated());
ASSERT_EQ(13047429345000000, new_date_created[0]);
ASSERT_EQ(13047423600000000, new_date_created[1]);
- // Check that the two dates match up.
- for (size_t i = 0; i < date_created.size(); ++i) {
- EXPECT_EQ(base::Time::FromInternalValue(new_date_created[i]),
- base::Time::FromTimeT(date_created[i]));
+ if (table_version <= 8) {
+ // Check that the two dates match up.
+ for (size_t i = 0; i < date_created.size(); ++i) {
+ EXPECT_EQ(base::Time::FromInternalValue(new_date_created[i]),
+ base::Time::FromTimeT(date_created[i]));
+ }
}
DestroyDatabase();
}
« no previous file with comments | « components/password_manager/core/browser/login_database.cc ('k') | components/test/data/password_manager/login_db_v9.sql » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698