| Index: chrome/browser/password_manager/password_store_mac_unittest.cc
|
| diff --git a/chrome/browser/password_manager/password_store_mac_unittest.cc b/chrome/browser/password_manager/password_store_mac_unittest.cc
|
| index a90341a6c615d6aa328a893aed5ae335a406d359..453879bd52dc613e9563f40a0c773b8a34c15aad 100644
|
| --- a/chrome/browser/password_manager/password_store_mac_unittest.cc
|
| +++ b/chrome/browser/password_manager/password_store_mac_unittest.cc
|
| @@ -6,7 +6,6 @@
|
|
|
| #include "base/basictypes.h"
|
| #include "base/files/scoped_temp_dir.h"
|
| -#include "base/memory/scoped_vector.h"
|
| #include "base/scoped_observer.h"
|
| #include "base/stl_util.h"
|
| #include "base/strings/string_util.h"
|
| @@ -482,11 +481,11 @@ TEST_F(PasswordStoreMacInternalsTest, TestKeychainSearch) {
|
| CreatePasswordFormFromData(test_data[i].data));
|
|
|
| // Check matches treating the form as a fill target.
|
| - std::vector<PasswordForm*> matching_items =
|
| - keychain_adapter.PasswordsFillingForm(query_form->signon_realm,
|
| - query_form->scheme);
|
| + ScopedVector<autofill::PasswordForm> matching_items;
|
| + keychain_adapter.PasswordsFillingForm(query_form->signon_realm,
|
| + query_form->scheme, &matching_items);
|
| EXPECT_EQ(test_data[i].expected_fill_matches, matching_items.size());
|
| - STLDeleteElements(&matching_items);
|
| + matching_items.clear();
|
|
|
| // Check matches treating the form as a merging target.
|
| EXPECT_EQ(test_data[i].expected_merge_matches > 0,
|
| @@ -496,9 +495,8 @@ TEST_F(PasswordStoreMacInternalsTest, TestKeychainSearch) {
|
| internal_keychain_helpers::
|
| ExtractAllKeychainItemAttributesIntoPasswordForms(&keychain_items,
|
| *keychain_);
|
| - matching_items =
|
| - internal_keychain_helpers::ExtractPasswordsMergeableWithForm(
|
| - *keychain_, item_form_pairs, *query_form);
|
| + internal_keychain_helpers::ExtractPasswordsMergeableWithForm(
|
| + *keychain_, item_form_pairs, *query_form, &matching_items);
|
| EXPECT_EQ(test_data[i].expected_merge_matches, matching_items.size());
|
| STLDeleteContainerPairSecondPointers(item_form_pairs.begin(),
|
| item_form_pairs.end());
|
| @@ -506,14 +504,13 @@ TEST_F(PasswordStoreMacInternalsTest, TestKeychainSearch) {
|
| i != keychain_items.end(); ++i) {
|
| keychain_->Free(*i);
|
| }
|
| - STLDeleteElements(&matching_items);
|
| + matching_items.clear();
|
|
|
| // None of the pre-seeded items are owned by us, so none should match an
|
| // owned-passwords-only search.
|
| - matching_items = owned_keychain_adapter.PasswordsFillingForm(
|
| - query_form->signon_realm, query_form->scheme);
|
| + owned_keychain_adapter.PasswordsFillingForm(
|
| + query_form->signon_realm, query_form->scheme, &matching_items);
|
| EXPECT_EQ(0U, matching_items.size());
|
| - STLDeleteElements(&matching_items);
|
| }
|
| }
|
|
|
| @@ -567,7 +564,7 @@ TEST_F(PasswordStoreMacInternalsTest, TestKeychainExactSearch) {
|
|
|
| // Make sure that the matching isn't looser than it should be by checking
|
| // that slightly altered forms don't match.
|
| - std::vector<PasswordForm*> modified_forms;
|
| + ScopedVector<autofill::PasswordForm> modified_forms;
|
|
|
| modified_forms.push_back(new PasswordForm(*base_form));
|
| modified_forms.back()->username_value = ASCIIToUTF16("wrong_user");
|
| @@ -596,7 +593,6 @@ TEST_F(PasswordStoreMacInternalsTest, TestKeychainExactSearch) {
|
| EXPECT_FALSE(match) << "In modified version " << j
|
| << " of base form " << i;
|
| }
|
| - STLDeleteElements(&modified_forms);
|
| }
|
| }
|
|
|
| @@ -890,33 +886,30 @@ TEST_F(PasswordStoreMacInternalsTest, TestFormMerge) {
|
| &merged_user_1_with_both_paths);
|
|
|
| for (unsigned int test_case = 0; test_case <= current_test; ++test_case) {
|
| - std::vector<PasswordForm*> keychain_forms;
|
| + ScopedVector<autofill::PasswordForm> keychain_forms;
|
| for (std::vector<PasswordFormData*>::iterator i =
|
| test_data[KEYCHAIN_INPUT][test_case].begin();
|
| i != test_data[KEYCHAIN_INPUT][test_case].end(); ++i) {
|
| keychain_forms.push_back(CreatePasswordFormFromData(*(*i)));
|
| }
|
| - std::vector<PasswordForm*> database_forms;
|
| + ScopedVector<autofill::PasswordForm> database_forms;
|
| for (std::vector<PasswordFormData*>::iterator i =
|
| test_data[DATABASE_INPUT][test_case].begin();
|
| i != test_data[DATABASE_INPUT][test_case].end(); ++i) {
|
| database_forms.push_back(CreatePasswordFormFromData(*(*i)));
|
| }
|
|
|
| - std::vector<PasswordForm*> merged_forms;
|
| + ScopedVector<autofill::PasswordForm> merged_forms;
|
| internal_keychain_helpers::MergePasswordForms(&keychain_forms,
|
| &database_forms,
|
| &merged_forms);
|
|
|
| - CHECK_FORMS(keychain_forms, test_data[KEYCHAIN_OUTPUT][test_case],
|
| + CHECK_FORMS(keychain_forms.get(), test_data[KEYCHAIN_OUTPUT][test_case],
|
| test_case);
|
| - CHECK_FORMS(database_forms, test_data[DATABASE_OUTPUT][test_case],
|
| + CHECK_FORMS(database_forms.get(), test_data[DATABASE_OUTPUT][test_case],
|
| + test_case);
|
| + CHECK_FORMS(merged_forms.get(), test_data[MERGE_OUTPUT][test_case],
|
| test_case);
|
| - CHECK_FORMS(merged_forms, test_data[MERGE_OUTPUT][test_case], test_case);
|
| -
|
| - STLDeleteElements(&keychain_forms);
|
| - STLDeleteElements(&database_forms);
|
| - STLDeleteElements(&merged_forms);
|
| }
|
| }
|
|
|
| @@ -946,21 +939,18 @@ TEST_F(PasswordStoreMacInternalsTest, TestPasswordBulkLookup) {
|
| L"submit", L"username", L"password", NULL, NULL,
|
| true, false, 1212121212 },
|
| };
|
| - std::vector<PasswordForm*> database_forms;
|
| + ScopedVector<autofill::PasswordForm> database_forms;
|
| for (unsigned int i = 0; i < arraysize(db_data); ++i) {
|
| database_forms.push_back(CreatePasswordFormFromData(db_data[i]));
|
| }
|
| - std::vector<PasswordForm*> merged_forms =
|
| - internal_keychain_helpers::GetPasswordsForForms(*keychain_,
|
| - &database_forms);
|
| + ScopedVector<autofill::PasswordForm> merged_forms;
|
| + internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms,
|
| + &merged_forms);
|
| EXPECT_EQ(2U, database_forms.size());
|
| ASSERT_EQ(3U, merged_forms.size());
|
| EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[0]->password_value);
|
| EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[1]->password_value);
|
| EXPECT_TRUE(merged_forms[2]->blacklisted_by_user);
|
| -
|
| - STLDeleteElements(&database_forms);
|
| - STLDeleteElements(&merged_forms);
|
| }
|
|
|
| TEST_F(PasswordStoreMacInternalsTest, TestBlacklistedFiltering) {
|
| @@ -976,18 +966,15 @@ TEST_F(PasswordStoreMacInternalsTest, TestBlacklistedFiltering) {
|
| L"submit", L"username", L"password", L"joe_user", L"non_empty_password",
|
| true, false, 1240000000 },
|
| };
|
| - std::vector<PasswordForm*> database_forms;
|
| + ScopedVector<autofill::PasswordForm> database_forms;
|
| for (unsigned int i = 0; i < arraysize(db_data); ++i) {
|
| database_forms.push_back(CreatePasswordFormFromData(db_data[i]));
|
| }
|
| - std::vector<PasswordForm*> merged_forms =
|
| - internal_keychain_helpers::GetPasswordsForForms(*keychain_,
|
| - &database_forms);
|
| + ScopedVector<autofill::PasswordForm> merged_forms;
|
| + internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms,
|
| + &merged_forms);
|
| EXPECT_EQ(2U, database_forms.size());
|
| ASSERT_EQ(0U, merged_forms.size());
|
| -
|
| - STLDeleteElements(&database_forms);
|
| - STLDeleteElements(&merged_forms);
|
| }
|
|
|
| TEST_F(PasswordStoreMacInternalsTest, TestFillPasswordFormFromKeychainItem) {
|
| @@ -1087,15 +1074,13 @@ TEST_F(PasswordStoreMacInternalsTest, TestPasswordGetAll) {
|
| owned_keychain_adapter.AddPassword(*form);
|
| }
|
|
|
| - std::vector<PasswordForm*> all_passwords =
|
| - keychain_adapter.GetAllPasswordFormPasswords();
|
| + ScopedVector<autofill::PasswordForm> all_passwords;
|
| + keychain_adapter.GetAllPasswordFormPasswords(&all_passwords);
|
| EXPECT_EQ(8 + arraysize(owned_password_data), all_passwords.size());
|
| - STLDeleteElements(&all_passwords);
|
|
|
| - std::vector<PasswordForm*> owned_passwords =
|
| - owned_keychain_adapter.GetAllPasswordFormPasswords();
|
| + ScopedVector<autofill::PasswordForm> owned_passwords;
|
| + owned_keychain_adapter.GetAllPasswordFormPasswords(&owned_passwords);
|
| EXPECT_EQ(arraysize(owned_password_data), owned_passwords.size());
|
| - STLDeleteElements(&owned_passwords);
|
| }
|
|
|
| #pragma mark -
|
| @@ -1237,9 +1222,9 @@ TEST_F(PasswordStoreMacTest, TestStoreUpdate) {
|
| scoped_ptr<PasswordForm> query_form(
|
| CreatePasswordFormFromData(updates[i].form_data));
|
|
|
| - std::vector<PasswordForm*> matching_items =
|
| - keychain_adapter.PasswordsFillingForm(query_form->signon_realm,
|
| - query_form->scheme);
|
| + ScopedVector<autofill::PasswordForm> matching_items;
|
| + keychain_adapter.PasswordsFillingForm(query_form->signon_realm,
|
| + query_form->scheme, &matching_items);
|
| if (updates[i].password) {
|
| EXPECT_GT(matching_items.size(), 0U) << "iteration " << i;
|
| if (matching_items.size() >= 1)
|
| @@ -1248,12 +1233,11 @@ TEST_F(PasswordStoreMacTest, TestStoreUpdate) {
|
| } else {
|
| EXPECT_EQ(0U, matching_items.size()) << "iteration " << i;
|
| }
|
| - STLDeleteElements(&matching_items);
|
| + matching_items.clear();
|
|
|
| login_db()->GetLogins(*query_form, &matching_items);
|
| EXPECT_EQ(updates[i].password ? 1U : 0U, matching_items.size())
|
| << "iteration " << i;
|
| - STLDeleteElements(&matching_items);
|
| }
|
| }
|
|
|
| @@ -1304,16 +1288,16 @@ TEST_F(PasswordStoreMacTest, TestDBKeychainAssociation) {
|
| store_->RemoveLogin(m_form);
|
| FinishAsyncProcessing();
|
|
|
| - std::vector<PasswordForm*> matching_items;
|
| + ScopedVector<autofill::PasswordForm> matching_items;
|
| // No trace of www.facebook.com.
|
| - matching_items = owned_keychain_adapter.PasswordsFillingForm(
|
| - www_form->signon_realm, www_form->scheme);
|
| + owned_keychain_adapter.PasswordsFillingForm(
|
| + www_form->signon_realm, www_form->scheme, &matching_items);
|
| EXPECT_EQ(0u, matching_items.size());
|
| login_db()->GetLogins(*www_form, &matching_items);
|
| EXPECT_EQ(0u, matching_items.size());
|
| // No trace of m.facebook.com.
|
| - matching_items = owned_keychain_adapter.PasswordsFillingForm(
|
| - m_form.signon_realm, m_form.scheme);
|
| + owned_keychain_adapter.PasswordsFillingForm(m_form.signon_realm,
|
| + m_form.scheme, &matching_items);
|
| EXPECT_EQ(0u, matching_items.size());
|
| login_db()->GetLogins(m_form, &matching_items);
|
| EXPECT_EQ(0u, matching_items.size());
|
| @@ -1398,12 +1382,12 @@ void CheckRemoveLoginsBetween(PasswordStoreMacTest* test, bool check_created) {
|
| MacKeychainPasswordFormAdapter owned_keychain_adapter(test->keychain());
|
| owned_keychain_adapter.SetFindsOnlyOwnedItems(false);
|
| ScopedVector<PasswordForm> matching_items;
|
| - matching_items.get() = owned_keychain_adapter.PasswordsFillingForm(
|
| - form_facebook->signon_realm, form_facebook->scheme);
|
| + owned_keychain_adapter.PasswordsFillingForm(
|
| + form_facebook->signon_realm, form_facebook->scheme, &matching_items);
|
| EXPECT_EQ(1u, matching_items.size());
|
| matching_items.clear();
|
| - matching_items.get() = owned_keychain_adapter.PasswordsFillingForm(
|
| - form_other->signon_realm, form_other->scheme);
|
| + owned_keychain_adapter.PasswordsFillingForm(
|
| + form_other->signon_realm, form_other->scheme, &matching_items);
|
| EXPECT_EQ(1u, matching_items.size());
|
| matching_items.clear();
|
|
|
| @@ -1423,11 +1407,11 @@ void CheckRemoveLoginsBetween(PasswordStoreMacTest* test, bool check_created) {
|
| list.clear();
|
| observer.WaitAndVerify(test);
|
|
|
| - matching_items.get() = owned_keychain_adapter.PasswordsFillingForm(
|
| - form_facebook->signon_realm, form_facebook->scheme);
|
| + owned_keychain_adapter.PasswordsFillingForm(
|
| + form_facebook->signon_realm, form_facebook->scheme, &matching_items);
|
| EXPECT_EQ(0u, matching_items.size());
|
| - matching_items.get() = owned_keychain_adapter.PasswordsFillingForm(
|
| - form_other->signon_realm, form_other->scheme);
|
| + owned_keychain_adapter.PasswordsFillingForm(
|
| + form_other->signon_realm, form_other->scheme, &matching_items);
|
| EXPECT_EQ(1u, matching_items.size());
|
| matching_items.clear();
|
|
|
| @@ -1438,8 +1422,8 @@ void CheckRemoveLoginsBetween(PasswordStoreMacTest* test, bool check_created) {
|
| password_manager::PasswordStoreChange::REMOVE, *form_other));
|
| EXPECT_CALL(observer, OnLoginsChanged(list));
|
| observer.WaitAndVerify(test);
|
| - matching_items.get() = owned_keychain_adapter.PasswordsFillingForm(
|
| - form_other->signon_realm, form_other->scheme);
|
| + owned_keychain_adapter.PasswordsFillingForm(
|
| + form_other->signon_realm, form_other->scheme, &matching_items);
|
| EXPECT_EQ(0u, matching_items.size());
|
| }
|
|
|
| @@ -1485,7 +1469,7 @@ TEST_F(PasswordStoreMacTest, TestRemoveLoginsMultiProfile) {
|
| FinishAsyncProcessing();
|
|
|
| ScopedVector<PasswordForm> matching_items;
|
| - login_db()->GetLogins(*www_form, &matching_items.get());
|
| + login_db()->GetLogins(*www_form, &matching_items);
|
| EXPECT_EQ(1u, matching_items.size());
|
| matching_items.clear();
|
|
|
| @@ -1493,20 +1477,21 @@ TEST_F(PasswordStoreMacTest, TestRemoveLoginsMultiProfile) {
|
| FinishAsyncProcessing();
|
|
|
| // Check the second facebook form is gone.
|
| - login_db()->GetLogins(*www_form, &matching_items.get());
|
| + login_db()->GetLogins(*www_form, &matching_items);
|
| EXPECT_EQ(0u, matching_items.size());
|
|
|
| // Check the first facebook form is still there.
|
| - matching_items.get() = owned_keychain_adapter.PasswordsFillingForm(
|
| - www_form->signon_realm, www_form->scheme);
|
| + owned_keychain_adapter.PasswordsFillingForm(
|
| + www_form->signon_realm, www_form->scheme, &matching_items);
|
| ASSERT_EQ(1u, matching_items.size());
|
| EXPECT_EQ(ASCIIToUTF16("joe_user"), matching_items[0]->username_value);
|
| matching_items.clear();
|
|
|
| // Check the third-party password is still there.
|
| owned_keychain_adapter.SetFindsOnlyOwnedItems(false);
|
| - matching_items.get() = owned_keychain_adapter.PasswordsFillingForm(
|
| - "http://some.domain.com/insecure.html", PasswordForm::SCHEME_HTML);
|
| + owned_keychain_adapter.PasswordsFillingForm(
|
| + "http://some.domain.com/insecure.html", PasswordForm::SCHEME_HTML,
|
| + &matching_items);
|
| ASSERT_EQ(1u, matching_items.size());
|
| }
|
|
|
|
|