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

Unified Diff: components/password_manager/core/browser/password_form_manager_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
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 236e882898a51d3fb2287de6e7ba8843b1e4b70c..536918069892107344fb4abbfe176389d679ccd2 100644
--- a/components/password_manager/core/browser/password_form_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_form_manager_unittest.cc
@@ -138,21 +138,22 @@ class TestPasswordManager : public PasswordManager {
const autofill::PasswordFormMap& best_matches,
const autofill::PasswordForm& preferred_match,
bool wait_for_username) const override {
- best_matches_ = best_matches;
+ best_matches_ = &best_matches;
wait_for_username_ = wait_for_username;
}
const autofill::PasswordFormMap& GetLatestBestMatches() {
- return best_matches_;
+ return *best_matches_;
}
bool GetLatestWaitForUsername() { return wait_for_username_; }
private:
+ // Points to a PasswordFormMap owned by PasswordFormManager.
// Marked mutable to get around constness of Autofill().
// TODO(vabr): This should be rewritten as a mock of PasswordManager, and the
// interesting arguments should be saved via GMock actions instead.
- mutable autofill::PasswordFormMap best_matches_;
+ mutable const autofill::PasswordFormMap* best_matches_;
mutable bool wait_for_username_;
};
@@ -221,10 +222,10 @@ class PasswordFormManagerTest : public testing::Test {
if (result == RESULT_NO_MATCH)
return;
- PasswordForm* match = new PasswordForm(saved_match_);
- // Heap-allocated form is owned by p.
- p->best_matches_[match->username_value] = match;
- p->preferred_match_ = match;
+ scoped_ptr<PasswordForm> match(new PasswordForm(saved_match_));
+ p->preferred_match_ = match.get();
+ base::string16 username = match->username_value;
+ p->best_matches_.insert(username, match.Pass());
}
void SanitizePossibleUsernames(PasswordFormManager* p, PasswordForm* form) {
« no previous file with comments | « components/password_manager/core/browser/password_form_manager.cc ('k') | components/policy/core/common/schema.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698