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 b5562617a30f02f010fd96d7180c176502df99c4..1668dbc5ee271b334bad90f17f9f206e696ffc8a 100644 |
--- a/components/password_manager/core/browser/login_database_unittest.cc |
+++ b/components/password_manager/core/browser/login_database_unittest.cc |
@@ -65,7 +65,7 @@ void GenerateExamplePasswordForm(PasswordForm* form) { |
form->display_name = ASCIIToUTF16("Mr. Smith"); |
form->avatar_url = GURL("https://accounts.google.com/Avatar"); |
form->federation_url = GURL("https://accounts.google.com/federation"); |
- form->is_zero_click = true; |
+ form->skip_next_zero_click = true; |
} |
} // namespace |
@@ -617,7 +617,7 @@ static bool AddTimestampedLogin(LoginDatabase* db, |
form.display_name = ASCIIToUTF16(unique_string); |
form.avatar_url = GURL("https://accounts.google.com/Avatar"); |
form.federation_url = GURL("https://accounts.google.com/federation"); |
- form.is_zero_click = true; |
+ form.skip_next_zero_click = true; |
if (date_is_creation) |
form.date_created = time; |
@@ -741,7 +741,7 @@ TEST_F(LoginDatabaseTest, BlacklistedLogins) { |
form.display_name = ASCIIToUTF16("Mr. Smith"); |
form.avatar_url = GURL("https://accounts.google.com/Avatar"); |
form.federation_url = GURL("https://accounts.google.com/federation"); |
- form.is_zero_click = true; |
+ form.skip_next_zero_click = true; |
EXPECT_EQ(AddChangeForForm(form), db().AddLogin(form)); |
// Get all non-blacklisted logins (should be none). |
@@ -980,7 +980,7 @@ TEST_F(LoginDatabaseTest, UpdateLogin) { |
form.display_name = ASCIIToUTF16("Mr. Smith"); |
form.avatar_url = GURL("https://accounts.google.com/Avatar"); |
form.federation_url = GURL("https://accounts.google.com/federation"); |
- form.is_zero_click = true; |
+ form.skip_next_zero_click = true; |
EXPECT_EQ(UpdateChangeForForm(form), db().UpdateLogin(form)); |
ScopedVector<autofill::PasswordForm> result; |
@@ -1135,8 +1135,8 @@ class LoginDatabaseMigrationTest : public testing::Test { |
return results; |
sql::Statement s(db.GetCachedStatement( |
- SQL_FROM_HERE, |
- "SELECT date_created from logins order by username_value")); |
+ SQL_FROM_HERE, "SELECT date_created FROM logins " |
+ "ORDER BY username_value, date_created DESC")); |
Mike West
2015/02/03 14:15:41
Hrm. It seems like this fix ought to be in a separ
vasilii
2015/02/03 19:49:17
The new thing is "date_created DESC". I needed it
|
if (!s.is_valid()) { |
db.Close(); |
return results; |
@@ -1158,26 +1158,18 @@ class LoginDatabaseMigrationTest : public testing::Test { |
}; |
// Tests the migration of the login database from version 1 to version |
-// kCurrentVersionNumber. This test will fail when kCurrentVersionNumber |
-// will be changed to 10, because file login_db_v10.sql doesn't exist. |
-// It has to be added in order to fix test. |
+// kCurrentVersionNumber. |
TEST_F(LoginDatabaseMigrationTest, MigrationV1ToVCurrent) { |
- 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); |
+ for (int version = 1; version < kCurrentVersionNumber; ++version) { |
+ CreateDatabase(base::IntToString(version)); |
SCOPED_TRACE(testing::Message("Version = ") << version); |
// Original date, in seconds since UTC epoch. |
std::vector<int64_t> date_created(GetDateCreated()); |
- int table_version; |
- base::StringToInt(version, &table_version); |
+ ASSERT_EQ(2U, date_created.size()); |
// 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) { |
+ if (version <= 8) { |
ASSERT_EQ(1402955745, date_created[0]); |
ASSERT_EQ(1402950000, date_created[1]); |
} else { |
@@ -1191,26 +1183,37 @@ TEST_F(LoginDatabaseMigrationTest, MigrationV1ToVCurrent) { |
LoginDatabase db(database_path_); |
ASSERT_TRUE(db.Init()); |
// Verifies that the final version can save all the appropriate fields. |
- ScopedVector<autofill::PasswordForm> result; |
PasswordForm form; |
GenerateExamplePasswordForm(&form); |
- db.AddLogin(form); |
+ // Double add should fail due to constraints in the database. |
+ EXPECT_EQ(AddChangeForForm(form), db.AddLogin(form)); |
+ PasswordStoreChangeList list; |
+ list.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); |
+ list.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); |
+ EXPECT_EQ(list, db.AddLogin(form)); |
+ |
+ ScopedVector<autofill::PasswordForm> result; |
EXPECT_TRUE(db.GetLogins(form, &result)); |
ASSERT_EQ(1U, result.size()); |
FormsAreEqual(form, *result[0]); |
EXPECT_TRUE(db.RemoveLogin(form)); |
- result.clear(); |
} |
// New date, in microseconds since platform independent epoch. |
std::vector<int64_t> new_date_created(GetDateCreated()); |
- ASSERT_EQ(13047429345000000, new_date_created[0]); |
- ASSERT_EQ(13047423600000000, new_date_created[1]); |
- if (table_version <= 8) { |
+ if (version <= 8) { |
+ ASSERT_EQ(2U, new_date_created.size()); |
// 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])); |
} |
+ } else if (version == 10) { |
+ // Two forms were merged. |
+ EXPECT_EQ(1U, new_date_created.size()); |
+ } else { |
+ ASSERT_EQ(2U, new_date_created.size()); |
+ ASSERT_EQ(13047429345000000, new_date_created[0]); |
+ ASSERT_EQ(13047423600000000, new_date_created[1]); |
} |
DestroyDatabase(); |
} |