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

Unified Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc

Issue 1096983002: Update usages of std::map to use ScopedPtrMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passwordmanager-scopedmemory
Patch Set: Rebase. Created 5 years, 6 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 | « chrome/browser/ui/passwords/manage_passwords_test.cc ('k') | chromeos/dbus/gsm_sms_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc
diff --git a/chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc b/chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc
index b5c3cec7735550633e779cea316f47504484b2ca..ddf92ce36605aede411820972f9b8395244cbbc5 100644
--- a/chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc
@@ -155,19 +155,22 @@ TEST_F(ManagePasswordsUIControllerTest, DefaultState) {
}
TEST_F(ManagePasswordsUIControllerTest, PasswordAutofilled) {
- base::string16 kTestUsername = test_local_form().username_value;
+ scoped_ptr<autofill::PasswordForm> test_form(
+ new autofill::PasswordForm(test_local_form()));
+ autofill::PasswordForm* test_form_ptr = test_form.get();
+ base::string16 kTestUsername = test_form->username_value;
autofill::PasswordFormMap map;
- map[kTestUsername] = &test_local_form();
+ map.insert(kTestUsername, test_form.Pass());
controller()->OnPasswordAutofilled(map);
EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->state());
EXPECT_FALSE(controller()->PasswordPendingUserDecision());
- EXPECT_EQ(test_local_form().origin, controller()->origin());
+ EXPECT_EQ(test_form_ptr->origin, controller()->origin());
ASSERT_EQ(1u, controller()->GetCurrentForms().size());
EXPECT_EQ(kTestUsername, controller()->GetCurrentForms()[0]->username_value);
// Controller should store a separate copy of the form as it doesn't own it.
- EXPECT_NE(&test_local_form(), controller()->GetCurrentForms()[0]);
+ EXPECT_NE(test_form_ptr, controller()->GetCurrentForms()[0]);
ManagePasswordsIconMock mock;
controller()->UpdateIconAndBubbleState(&mock);
@@ -288,20 +291,23 @@ TEST_F(ManagePasswordsUIControllerTest, PasswordSubmittedToNonWebbyURL) {
}
TEST_F(ManagePasswordsUIControllerTest, BlacklistBlockedAutofill) {
- test_local_form().blacklisted_by_user = true;
- base::string16 kTestUsername = test_local_form().username_value;
+ scoped_ptr<autofill::PasswordForm> test_form(
+ new autofill::PasswordForm(test_local_form()));
+ autofill::PasswordForm* test_form_ptr = test_form.get();
+ test_form->blacklisted_by_user = true;
+ base::string16 kTestUsername = test_form->username_value;
autofill::PasswordFormMap map;
- map[kTestUsername] = &test_local_form();
+ map.insert(kTestUsername, test_form.Pass());
controller()->OnBlacklistBlockedAutofill(map);
EXPECT_EQ(password_manager::ui::BLACKLIST_STATE, controller()->state());
EXPECT_FALSE(controller()->PasswordPendingUserDecision());
- EXPECT_EQ(test_local_form().origin, controller()->origin());
+ EXPECT_EQ(test_form_ptr->origin, controller()->origin());
ASSERT_EQ(1u, controller()->GetCurrentForms().size());
EXPECT_EQ(kTestUsername, controller()->GetCurrentForms()[0]->username_value);
// Controller should store a separate copy of the form as it doesn't own it.
- EXPECT_NE(&test_local_form(), controller()->GetCurrentForms()[0]);
+ EXPECT_NE(test_form_ptr, controller()->GetCurrentForms()[0]);
ManagePasswordsIconMock mock;
controller()->UpdateIconAndBubbleState(&mock);
@@ -311,8 +317,11 @@ TEST_F(ManagePasswordsUIControllerTest, BlacklistBlockedAutofill) {
TEST_F(ManagePasswordsUIControllerTest, ClickedUnblacklist) {
base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
autofill::PasswordFormMap map;
- map[kTestUsername] = &test_local_form();
- test_local_form().blacklisted_by_user = true;
+ scoped_ptr<autofill::PasswordForm> test_form(
+ new autofill::PasswordForm(test_local_form()));
+ autofill::PasswordForm& test_form_ref = *test_form;
+ map.insert(kTestUsername, test_form.Pass());
+ test_form_ref.blacklisted_by_user = true;
controller()->OnBlacklistBlockedAutofill(map);
controller()->UnblacklistSite();
@@ -329,7 +338,8 @@ TEST_F(ManagePasswordsUIControllerTest, UnblacklistedElsewhere) {
test_local_form().blacklisted_by_user = true;
base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
autofill::PasswordFormMap map;
- map[kTestUsername] = &test_local_form();
+ map.insert(kTestUsername,
+ make_scoped_ptr(new autofill::PasswordForm(test_local_form())));
controller()->OnBlacklistBlockedAutofill(map);
password_manager::PasswordStoreChange change(
@@ -349,7 +359,8 @@ TEST_F(ManagePasswordsUIControllerTest, UnblacklistedElsewhere) {
TEST_F(ManagePasswordsUIControllerTest, BlacklistedElsewhere) {
base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
autofill::PasswordFormMap map;
- map[kTestUsername] = &test_local_form();
+ map.insert(kTestUsername,
+ make_scoped_ptr(new autofill::PasswordForm(test_local_form())));
controller()->OnPasswordAutofilled(map);
test_local_form().blacklisted_by_user = true;
@@ -543,9 +554,11 @@ TEST_F(ManagePasswordsUIControllerTest, AutoSigninClickThrough) {
TEST_F(ManagePasswordsUIControllerTest, InactiveOnPSLMatched) {
base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
autofill::PasswordFormMap map;
- autofill::PasswordForm psl_matched_test_form = test_local_form();
- psl_matched_test_form.original_signon_realm = "http://pslmatched.example.com";
- map[kTestUsername] = &psl_matched_test_form;
+ scoped_ptr<autofill::PasswordForm> psl_matched_test_form(
+ new autofill::PasswordForm(test_local_form()));
+ psl_matched_test_form->original_signon_realm =
+ "http://pslmatched.example.com";
+ map.insert(kTestUsername, psl_matched_test_form.Pass());
controller()->OnPasswordAutofilled(map);
EXPECT_EQ(password_manager::ui::INACTIVE_STATE, controller()->state());
« no previous file with comments | « chrome/browser/ui/passwords/manage_passwords_test.cc ('k') | chromeos/dbus/gsm_sms_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698