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

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

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 5 years 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/password_form_manager_unittest.cc
diff --git a/components/password_manager/core/browser/password_form_manager_unittest.cc b/components/password_manager/core/browser/password_form_manager_unittest.cc
index 06e4cdb2000981e45b8082e42eee015f63ce4f0b..e9e1571c00028378d3a852d4451b42d26b32f212 100644
--- a/components/password_manager/core/browser/password_form_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_form_manager_unittest.cc
@@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "components/password_manager/core/browser/password_form_manager.h"
+
#include <map>
+#include <utility>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
@@ -21,7 +24,6 @@
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/credentials_filter.h"
#include "components/password_manager/core/browser/mock_password_store.h"
-#include "components/password_manager/core/browser/password_form_manager.h"
#include "components/password_manager/core/browser/password_manager.h"
#include "components/password_manager/core/browser/password_manager_driver.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
@@ -56,7 +58,7 @@ ACTION_P4(InvokeConsumer, form1, form2, form3, form4) {
result.push_back(make_scoped_ptr(new PasswordForm(form2)));
result.push_back(make_scoped_ptr(new PasswordForm(form3)));
result.push_back(make_scoped_ptr(new PasswordForm(form4)));
- arg0->OnGetPasswordStoreResults(result.Pass());
+ arg0->OnGetPasswordStoreResults(std::move(result));
}
MATCHER_P(CheckUsername, username_value, "Username incorrect") {
@@ -138,7 +140,7 @@ class MockPasswordManagerDriver : public StubPasswordManagerDriver {
scoped_ptr<TestingPrefServiceSimple> prefs(new TestingPrefServiceSimple());
prefs->registry()->RegisterBooleanPref(autofill::prefs::kAutofillEnabled,
true);
- test_autofill_client_.SetPrefs(prefs.Pass());
+ test_autofill_client_.SetPrefs(std::move(prefs));
mock_autofill_download_manager_ = new MockAutofillDownloadManager(
&test_autofill_driver_, &mock_autofill_manager_);
// AutofillManager takes ownership of |mock_autofill_download_manager_|.
@@ -180,7 +182,7 @@ class MockStoreResultFilter : public CredentialsFilter {
ScopedVector<autofill::PasswordForm> FilterResults(
ScopedVector<autofill::PasswordForm> results) const override {
FilterResultsPtr(&results);
- return results.Pass();
+ return results;
}
};
@@ -333,7 +335,7 @@ class PasswordFormManagerTest : public testing::Test {
if (result & RESULT_PSL_MATCH) {
result_form.push_back(new PasswordForm(psl_saved_match_));
}
- p->OnGetPasswordStoreResults(result_form.Pass());
+ p->OnGetPasswordStoreResults(std::move(result_form));
}
// Save saved_match() for observed_form() where |observed_form_data|,
@@ -369,7 +371,7 @@ class PasswordFormManagerTest : public testing::Test {
: base::string16();
form_manager.SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager.OnGetPasswordStoreResults(result.Pass());
+ form_manager.OnGetPasswordStoreResults(std::move(result));
std::string expected_login_signature;
autofill::FormStructure observed_structure(observed_form_data);
autofill::FormStructure pending_structure(saved_match()->form_data);
@@ -652,7 +654,7 @@ TEST_F(PasswordFormManagerTest, TestBlacklistMatching) {
result.push_back(new PasswordForm(blacklisted_not_match2));
result.push_back(new PasswordForm(blacklisted_match));
result.push_back(new PasswordForm(*saved_match()));
- form_manager.OnGetPasswordStoreResults(result.Pass());
+ form_manager.OnGetPasswordStoreResults(std::move(result));
EXPECT_TRUE(form_manager.IsBlacklisted());
EXPECT_THAT(form_manager.blacklisted_matches(),
ElementsAre(Pointee(blacklisted_match)));
@@ -681,7 +683,7 @@ TEST_F(PasswordFormManagerTest, AutofillBlacklisted) {
EXPECT_CALL(*client()->mock_driver(), FillPasswordForm(_))
.WillOnce(SaveArg<0>(&fill_data));
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
EXPECT_EQ(1u, form_manager()->blacklisted_matches().size());
EXPECT_TRUE(form_manager()->IsBlacklisted());
EXPECT_EQ(1u, form_manager()->best_matches().size());
@@ -889,7 +891,7 @@ TEST_F(PasswordFormManagerTest, TestIgnoreResult_SSL) {
saved_form.ssl_valid = kObservedFormSSLValid;
result.push_back(new PasswordForm(saved_form));
form_manager.SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager.OnGetPasswordStoreResults(result.Pass());
+ form_manager.OnGetPasswordStoreResults(std::move(result));
// Make sure we don't match a PasswordForm if it was originally saved on
// an SSL-valid page and we are now on a page with invalid certificate.
@@ -912,7 +914,7 @@ TEST_F(PasswordFormManagerTest, TestIgnoreResult_Paths) {
ScopedVector<PasswordForm> result;
result.push_back(new PasswordForm(saved_form));
form_manager.SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager.OnGetPasswordStoreResults(result.Pass());
+ form_manager.OnGetPasswordStoreResults(std::move(result));
// Different paths for action / origin are okay.
EXPECT_FALSE(form_manager.best_matches().empty());
@@ -932,7 +934,7 @@ TEST_F(PasswordFormManagerTest, TestIgnoreResult_IgnoredCredentials) {
ScopedVector<PasswordForm> result;
result.push_back(new PasswordForm(saved_form));
form_manager.SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager.OnGetPasswordStoreResults(result.Pass());
+ form_manager.OnGetPasswordStoreResults(std::move(result));
// Results should be ignored if the client requests it.
EXPECT_TRUE(form_manager.best_matches().empty());
@@ -995,7 +997,7 @@ TEST_F(PasswordFormManagerTest, TestAlternateUsername_NoChange) {
ScopedVector<PasswordForm> result;
result.push_back(new PasswordForm(saved_form));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
// The saved match has the right username already.
PasswordForm login(*observed_form());
@@ -1032,7 +1034,7 @@ TEST_F(PasswordFormManagerTest, TestAlternateUsername_OtherUsername) {
ScopedVector<PasswordForm> result;
result.push_back(new PasswordForm(saved_form));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
// The saved match has the right username already.
PasswordForm login(*observed_form());
@@ -1081,7 +1083,7 @@ TEST_F(PasswordFormManagerTest, TestSendNotBlacklistedMessage_Credentials) {
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
ScopedVector<PasswordForm> simulated_results;
simulated_results.push_back(CreateSavedMatch(false));
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
}
TEST_F(PasswordFormManagerTest,
@@ -1099,7 +1101,7 @@ TEST_F(PasswordFormManagerTest,
form_manager.SimulateFetchMatchingLoginsFromPasswordStore();
ScopedVector<PasswordForm> simulated_results;
simulated_results.push_back(CreateSavedMatch(false));
- form_manager.OnGetPasswordStoreResults(simulated_results.Pass());
+ form_manager.OnGetPasswordStoreResults(std::move(simulated_results));
}
TEST_F(PasswordFormManagerTest,
@@ -1111,7 +1113,7 @@ TEST_F(PasswordFormManagerTest,
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
ScopedVector<PasswordForm> simulated_results;
simulated_results.push_back(CreateSavedMatch(true));
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
}
TEST_F(PasswordFormManagerTest, TestForceInclusionOfGeneratedPasswords_Match) {
@@ -1132,7 +1134,7 @@ TEST_F(PasswordFormManagerTest, TestForceInclusionOfGeneratedPasswords_Match) {
EXPECT_CALL(*client()->mock_driver(), FillPasswordForm(_))
.WillOnce(SaveArg<0>(&fill_data));
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
EXPECT_EQ(1u, form_manager()->best_matches().size());
EXPECT_TRUE(fill_data.additional_logins.empty());
}
@@ -1156,7 +1158,7 @@ TEST_F(PasswordFormManagerTest,
EXPECT_CALL(*client()->mock_driver(), FillPasswordForm(_))
.WillOnce(SaveArg<0>(&fill_data));
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
EXPECT_EQ(2u, form_manager()->best_matches().size());
EXPECT_EQ(1u, fill_data.additional_logins.size());
}
@@ -1271,8 +1273,8 @@ TEST_F(PasswordFormManagerTest, TestUpdateIncompleteCredentials) {
// Feed the incomplete credentials to the manager.
ScopedVector<PasswordForm> simulated_results;
- simulated_results.push_back(incomplete_form.Pass());
- form_manager.OnGetPasswordStoreResults(simulated_results.Pass());
+ simulated_results.push_back(std::move(incomplete_form));
+ form_manager.OnGetPasswordStoreResults(std::move(simulated_results));
form_manager.ProvisionallySave(
complete_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
@@ -1308,7 +1310,7 @@ TEST_F(PasswordFormManagerTest, TestScoringPublicSuffixMatch) {
EXPECT_CALL(*client()->mock_driver(), FillPasswordForm(_))
.WillOnce(SaveArg<0>(&fill_data));
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
EXPECT_TRUE(fill_data.additional_logins.empty());
EXPECT_EQ(1u, form_manager()->best_matches().size());
EXPECT_TRUE(
@@ -1334,7 +1336,7 @@ TEST_F(PasswordFormManagerTest, AndroidCredentialsAreAutofilled) {
EXPECT_CALL(*client()->mock_driver(), FillPasswordForm(_))
.WillOnce(SaveArg<0>(&fill_data));
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
EXPECT_TRUE(fill_data.additional_logins.empty());
EXPECT_FALSE(fill_data.wait_for_username);
EXPECT_EQ(1u, form_manager()->best_matches().size());
@@ -1376,7 +1378,7 @@ TEST_F(PasswordFormManagerTest, AndroidCredentialsAreProtected) {
EXPECT_CALL(*client()->mock_driver(), FillPasswordForm(_))
.WillOnce(SaveArg<0>(&fill_data));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
EXPECT_FALSE(fill_data.wait_for_username);
EXPECT_EQ(1u, fill_data.additional_logins.size());
@@ -1516,7 +1518,7 @@ TEST_F(PasswordFormManagerTest, CorrectlyUpdatePasswordsWithSameUsername) {
result.push_back(new PasswordForm(first));
result.push_back(new PasswordForm(second));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
// We always take the first credential with a particular username, regardless
// of which ones are labeled preferred.
@@ -1676,8 +1678,8 @@ TEST_F(PasswordFormManagerTest, DriverDeletedBeforeStoreDone) {
client()->KillDriver();
ScopedVector<PasswordForm> simulated_results;
- simulated_results.push_back(form.Pass());
- form_manager.OnGetPasswordStoreResults(simulated_results.Pass());
+ simulated_results.push_back(std::move(form));
+ form_manager.OnGetPasswordStoreResults(std::move(simulated_results));
}
TEST_F(PasswordFormManagerTest, PreferredMatchIsUpToDate) {
@@ -1699,10 +1701,10 @@ TEST_F(PasswordFormManagerTest, PreferredMatchIsUpToDate) {
generated_form->password_value = ASCIIToUTF16("password2");
generated_form->preferred = true;
- simulated_results.push_back(generated_form.Pass());
- simulated_results.push_back(form.Pass());
+ simulated_results.push_back(std::move(generated_form));
+ simulated_results.push_back(std::move(form));
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
EXPECT_EQ(1u, form_manager()->best_matches().size());
EXPECT_EQ(form_manager()->preferred_match(),
form_manager()->best_matches().begin()->second.get());
@@ -1824,7 +1826,7 @@ TEST_F(PasswordFormManagerTest, TestSuggestingPasswordChangeForms) {
EXPECT_CALL(*client()->mock_driver(), FillPasswordForm(_))
.WillOnce(SaveArg<0>(&fill_data));
- manager_creds.OnGetPasswordStoreResults(simulated_results.Pass());
+ manager_creds.OnGetPasswordStoreResults(std::move(simulated_results));
EXPECT_EQ(1u, manager_creds.best_matches().size());
EXPECT_EQ(0u, fill_data.additional_logins.size());
EXPECT_TRUE(fill_data.wait_for_username);
@@ -2052,7 +2054,7 @@ TEST_F(PasswordFormManagerTest, RemoveNoUsernameAccounts) {
ScopedVector<PasswordForm> result;
result.push_back(new PasswordForm(saved_form));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
PasswordForm submitted_form(*observed_form());
submitted_form.preferred = true;
@@ -2076,7 +2078,7 @@ TEST_F(PasswordFormManagerTest, NotRemovePSLNoUsernameAccounts) {
ScopedVector<PasswordForm> result;
result.push_back(new PasswordForm(saved_form));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
PasswordForm submitted_form(*observed_form());
submitted_form.preferred = true;
@@ -2098,7 +2100,7 @@ TEST_F(PasswordFormManagerTest, NotRemoveCredentialsWithUsername) {
ScopedVector<PasswordForm> result;
result.push_back(new PasswordForm(saved_form));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
PasswordForm submitted_form(*observed_form());
submitted_form.preferred = true;
@@ -2120,7 +2122,7 @@ TEST_F(PasswordFormManagerTest, NotRemoveCredentialsWithDiferrentPassword) {
ScopedVector<PasswordForm> result;
result.push_back(new PasswordForm(saved_form));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
PasswordForm submitted_form(*observed_form());
submitted_form.preferred = true;
@@ -2142,7 +2144,7 @@ TEST_F(PasswordFormManagerTest, SaveNoUsernameEvenIfWithUsernamePresent) {
ScopedVector<PasswordForm> result;
result.push_back(new PasswordForm(*saved_form));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
PasswordForm submitted_form(*observed_form());
submitted_form.preferred = true;
@@ -2165,7 +2167,7 @@ TEST_F(PasswordFormManagerTest, NotRemoveOnUpdate) {
saved_form.preferred = false;
result.push_back(new PasswordForm(saved_form));
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore();
- form_manager()->OnGetPasswordStoreResults(result.Pass());
+ form_manager()->OnGetPasswordStoreResults(std::move(result));
PasswordForm submitted_form(*observed_form());
submitted_form.preferred = true;
@@ -2198,8 +2200,8 @@ TEST_F(PasswordFormManagerTest, GenerationStatusChangedWithPassword) {
submitted_form.password_value = ASCIIToUTF16("password3");
ScopedVector<PasswordForm> simulated_results;
- simulated_results.push_back(generated_form.Pass());
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ simulated_results.push_back(std::move(generated_form));
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
form_manager()->ProvisionallySave(
submitted_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
@@ -2230,8 +2232,8 @@ TEST_F(PasswordFormManagerTest, GenerationStatusNotUpdatedIfPasswordUnchanged) {
PasswordForm submitted_form(*generated_form);
ScopedVector<PasswordForm> simulated_results;
- simulated_results.push_back(generated_form.Pass());
- form_manager()->OnGetPasswordStoreResults(simulated_results.Pass());
+ simulated_results.push_back(std::move(generated_form));
+ form_manager()->OnGetPasswordStoreResults(std::move(simulated_results));
form_manager()->ProvisionallySave(
submitted_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
@@ -2260,18 +2262,18 @@ TEST_F(PasswordFormManagerTest,
scoped_ptr<PasswordForm> saved_form(new PasswordForm(*saved_match()));
saved_form->username_value = ASCIIToUTF16("a@gmail.com");
ScopedVector<PasswordForm> results;
- results.push_back(saved_form.Pass());
- form_manager()->OnGetPasswordStoreResults(results.Pass());
+ results.push_back(std::move(saved_form));
+ form_manager()->OnGetPasswordStoreResults(std::move(results));
EXPECT_TRUE(form_manager()->best_matches().empty());
// Second response from the store should not be ignored.
saved_form.reset(new PasswordForm(*saved_match()));
saved_form->username_value = ASCIIToUTF16("b@gmail.com");
- results.push_back(saved_form.Pass());
+ results.push_back(std::move(saved_form));
saved_form.reset(new PasswordForm(*saved_match()));
saved_form->username_value = ASCIIToUTF16("c@gmail.com");
- results.push_back(saved_form.Pass());
- form_manager()->OnGetPasswordStoreResults(results.Pass());
+ results.push_back(std::move(saved_form));
+ form_manager()->OnGetPasswordStoreResults(std::move(results));
EXPECT_EQ(2U, form_manager()->best_matches().size());
}
@@ -2311,8 +2313,8 @@ TEST_F(PasswordFormManagerTest, ProcessFrame_DriverBeforeMatching) {
// Password store responds.
scoped_ptr<PasswordForm> match(new PasswordForm(*saved_match()));
ScopedVector<PasswordForm> result_form;
- result_form.push_back(match.Pass());
- form_manager()->OnGetPasswordStoreResults(result_form.Pass());
+ result_form.push_back(std::move(match));
+ form_manager()->OnGetPasswordStoreResults(std::move(result_form));
}
TEST_F(PasswordFormManagerTest, ProcessFrame_StoreUpdatesCausesAutofill) {

Powered by Google App Engine
This is Rietveld 408576698