summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 20:31:59 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 20:31:59 +0000
commit0df236b53b7ff5445b835ec3e02f39e2a4116282 (patch)
tree481f7dc9c943db0637a860ee7cdfd51235c5f7bb
parente2d30f69f10ba3dea88c44b7833fca05b23ac951 (diff)
downloadchromium_src-0df236b53b7ff5445b835ec3e02f39e2a4116282.zip
chromium_src-0df236b53b7ff5445b835ec3e02f39e2a4116282.tar.gz
chromium_src-0df236b53b7ff5445b835ec3e02f39e2a4116282.tar.bz2
AutoFillProfile: don't replicate logic in Clone()
BUG=none TEST=unit_tests --gtest_filter=AutoFillProfileTest.Clone Review URL: http://codereview.chromium.org/5608004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69047 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/autofill_profile.cc13
-rw-r--r--chrome/browser/autofill/autofill_profile_unittest.cc12
2 files changed, 13 insertions, 12 deletions
diff --git a/chrome/browser/autofill/autofill_profile.cc b/chrome/browser/autofill/autofill_profile.cc
index b269865..388b219 100644
--- a/chrome/browser/autofill/autofill_profile.cc
+++ b/chrome/browser/autofill/autofill_profile.cc
@@ -147,18 +147,7 @@ void AutoFillProfile::SetInfo(const AutoFillType& type, const string16& value) {
}
FormGroup* AutoFillProfile::Clone() const {
- AutoFillProfile* profile = new AutoFillProfile();
- profile->label_ = label_;
- profile->guid_ = guid();
-
- FormGroupMap::const_iterator iter;
- for (iter = personal_info_.begin(); iter != personal_info_.end(); ++iter) {
- if (profile->personal_info_.count(iter->first))
- delete profile->personal_info_[iter->first];
- profile->personal_info_[iter->first] = iter->second->Clone();
- }
-
- return profile;
+ return new AutoFillProfile(*this);
}
const string16 AutoFillProfile::Label() const {
diff --git a/chrome/browser/autofill/autofill_profile_unittest.cc b/chrome/browser/autofill/autofill_profile_unittest.cc
index 033fa57..f3fd1e5 100644
--- a/chrome/browser/autofill/autofill_profile_unittest.cc
+++ b/chrome/browser/autofill/autofill_profile_unittest.cc
@@ -511,6 +511,18 @@ TEST(AutoFillProfileTest, AssignmentOperator){
EXPECT_TRUE(a == b);
}
+TEST(AutoFillProfileTest, Clone) {
+ AutoFillProfile a;
+
+ // Clone should be logically equal to the original.
+ autofill_test::SetProfileInfo(&a, "Billing", "Marion", "Mitchell", "Morrison",
+ "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5",
+ "Hollywood", "CA", "91601", "US", "12345678910",
+ "01987654321");
+ scoped_ptr<AutoFillProfile> b(static_cast<AutoFillProfile*>(a.Clone()));
+ EXPECT_TRUE(a == *b);
+}
+
TEST(AutoFillProfileTest, Compare) {
AutoFillProfile a, b;