| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 class PersonalDataManagerMock : public PersonalDataManager { | 68 class PersonalDataManagerMock : public PersonalDataManager { |
| 69 public: | 69 public: |
| 70 PersonalDataManagerMock(); | 70 PersonalDataManagerMock(); |
| 71 virtual ~PersonalDataManagerMock(); | 71 virtual ~PersonalDataManagerMock(); |
| 72 | 72 |
| 73 // Reset the saved profiles. | 73 // Reset the saved profiles. |
| 74 void Reset(); | 74 void Reset(); |
| 75 | 75 |
| 76 // PersonalDataManager: | 76 // PersonalDataManager: |
| 77 virtual void SaveImportedProfile(const AutofillProfile& profile) OVERRIDE; | 77 virtual void SaveImportedProfile(const AutofillProfile& profile) OVERRIDE; |
| 78 virtual const std::vector<AutofillProfile*>& web_profiles() OVERRIDE; | 78 virtual const std::vector<AutofillProfile*>& web_profiles() const OVERRIDE; |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 ScopedVector<AutofillProfile> profiles_; | 81 ScopedVector<AutofillProfile> profiles_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerMock); | 83 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerMock); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 PersonalDataManagerMock::PersonalDataManagerMock() : PersonalDataManager() { | 86 PersonalDataManagerMock::PersonalDataManagerMock() : PersonalDataManager() { |
| 87 } | 87 } |
| 88 | 88 |
| 89 PersonalDataManagerMock::~PersonalDataManagerMock() { | 89 PersonalDataManagerMock::~PersonalDataManagerMock() { |
| 90 } | 90 } |
| 91 | 91 |
| 92 void PersonalDataManagerMock::Reset() { | 92 void PersonalDataManagerMock::Reset() { |
| 93 profiles_.reset(); | 93 profiles_.reset(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void PersonalDataManagerMock::SaveImportedProfile( | 96 void PersonalDataManagerMock::SaveImportedProfile( |
| 97 const AutofillProfile& profile) { | 97 const AutofillProfile& profile) { |
| 98 std::vector<AutofillProfile> profiles; | 98 std::vector<AutofillProfile> profiles; |
| 99 if (!MergeProfile(profile, profiles_.get(), &profiles)) | 99 if (!MergeProfile(profile, profiles_.get(), &profiles)) |
| 100 profiles_.push_back(new AutofillProfile(profile)); | 100 profiles_.push_back(new AutofillProfile(profile)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 const std::vector<AutofillProfile*>& PersonalDataManagerMock::web_profiles() { | 103 const std::vector<AutofillProfile*>& PersonalDataManagerMock::web_profiles() |
| 104 const { |
| 104 return profiles_.get(); | 105 return profiles_.get(); |
| 105 } | 106 } |
| 106 | 107 |
| 107 } // namespace | 108 } // namespace |
| 108 | 109 |
| 109 // A data-driven test for verifying merging of Autofill profiles. Each input is | 110 // A data-driven test for verifying merging of Autofill profiles. Each input is |
| 110 // a structured dump of a set of implicitly detected autofill profiles. The | 111 // a structured dump of a set of implicitly detected autofill profiles. The |
| 111 // corresponding output file is a dump of the saved profiles that result from | 112 // corresponding output file is a dump of the saved profiles that result from |
| 112 // importing the input profiles. The output file format is identical to the | 113 // importing the input profiles. The output file format is identical to the |
| 113 // input format. | 114 // input format. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 211 } |
| 211 } | 212 } |
| 212 | 213 |
| 213 *merged_profiles = SerializeProfiles(personal_data_->web_profiles()); | 214 *merged_profiles = SerializeProfiles(personal_data_->web_profiles()); |
| 214 } | 215 } |
| 215 | 216 |
| 216 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) { | 217 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) { |
| 217 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName), | 218 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName), |
| 218 kFileNamePattern); | 219 kFileNamePattern); |
| 219 } | 220 } |
| OLD | NEW |