OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/sync/test/integration/passwords_helper.h" | 5 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
6 | 6 |
| 7 #include <sstream> |
| 8 |
7 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
8 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
10 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
12 #include "chrome/browser/password_manager/password_store_factory.h" | 14 #include "chrome/browser/password_manager/password_store_factory.h" |
13 #include "chrome/browser/sync/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
14 #include "chrome/browser/sync/profile_sync_service_factory.h" | 16 #include "chrome/browser/sync/profile_sync_service_factory.h" |
15 #include "chrome/browser/sync/test/integration/multi_client_status_change_checke
r.h" | 17 #include "chrome/browser/sync/test/integration/multi_client_status_change_checke
r.h" |
16 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 18 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 PasswordStore* GetVerifierPasswordStore() { | 133 PasswordStore* GetVerifierPasswordStore() { |
132 return PasswordStoreFactory::GetForProfile( | 134 return PasswordStoreFactory::GetForProfile( |
133 test()->verifier(), ServiceAccessType::IMPLICIT_ACCESS).get(); | 135 test()->verifier(), ServiceAccessType::IMPLICIT_ACCESS).get(); |
134 } | 136 } |
135 | 137 |
136 bool ProfileContainsSamePasswordFormsAsVerifier(int index) { | 138 bool ProfileContainsSamePasswordFormsAsVerifier(int index) { |
137 ScopedVector<PasswordForm> verifier_forms = | 139 ScopedVector<PasswordForm> verifier_forms = |
138 GetLogins(GetVerifierPasswordStore()); | 140 GetLogins(GetVerifierPasswordStore()); |
139 ScopedVector<PasswordForm> forms = GetLogins(GetPasswordStore(index)); | 141 ScopedVector<PasswordForm> forms = GetLogins(GetPasswordStore(index)); |
140 ClearSyncDateField(&forms.get()); | 142 ClearSyncDateField(&forms.get()); |
141 bool result = password_manager::ContainsSamePasswordFormsPtr( | 143 |
142 verifier_forms.get(), forms.get()); | 144 std::ostringstream mismatch_details_stream; |
143 if (!result) { | 145 bool is_matching = password_manager::ContainsEqualPasswordFormsUnordered( |
144 VLOG(1) << "Password forms in Verifier Profile:"; | 146 verifier_forms.get(), forms.get(), &mismatch_details_stream); |
145 for (const PasswordForm* form : verifier_forms) { | 147 if (!is_matching) { |
146 VLOG(1) << *form; | 148 VLOG(1) << "Profile " << index |
147 } | 149 << " does not contain the same Password forms as Verifier Profile."; |
148 VLOG(1) << "Password forms in Profile" << index << ":"; | 150 VLOG(1) << mismatch_details_stream.str(); |
149 for (const PasswordForm* form : forms) { | |
150 VLOG(1) << *form; | |
151 } | |
152 } | 151 } |
153 return result; | 152 return is_matching; |
154 } | 153 } |
155 | 154 |
156 bool ProfilesContainSamePasswordForms(int index_a, int index_b) { | 155 bool ProfilesContainSamePasswordForms(int index_a, int index_b) { |
157 ScopedVector<PasswordForm> forms_a = GetLogins(GetPasswordStore(index_a)); | 156 ScopedVector<PasswordForm> forms_a = GetLogins(GetPasswordStore(index_a)); |
158 ScopedVector<PasswordForm> forms_b = GetLogins(GetPasswordStore(index_b)); | 157 ScopedVector<PasswordForm> forms_b = GetLogins(GetPasswordStore(index_b)); |
159 ClearSyncDateField(&forms_a.get()); | 158 ClearSyncDateField(&forms_a.get()); |
160 ClearSyncDateField(&forms_b.get()); | 159 ClearSyncDateField(&forms_b.get()); |
161 bool result = password_manager::ContainsSamePasswordFormsPtr(forms_a.get(), | 160 |
162 forms_b.get()); | 161 std::ostringstream mismatch_details_stream; |
163 if (!result) { | 162 bool is_matching = password_manager::ContainsEqualPasswordFormsUnordered( |
164 VLOG(1) << "Password forms in Profile" << index_a << ":"; | 163 forms_a.get(), forms_b.get(), &mismatch_details_stream); |
165 for (const PasswordForm* form : forms_a) { | 164 if (!is_matching) { |
166 VLOG(1) << *form; | 165 VLOG(1) << "Password forms in Profile " << index_a |
167 } | 166 << " (listed as 'expected forms' below)" |
168 VLOG(1) << "Password forms in Profile" << index_b << ":"; | 167 << " do not match those in Profile " << index_b |
169 for (const PasswordForm* form : forms_b) { | 168 << " (listed as 'actual forms' below)"; |
170 VLOG(1) << *form; | 169 VLOG(1) << mismatch_details_stream.str(); |
171 } | |
172 } | 170 } |
173 return result; | 171 return is_matching; |
174 } | 172 } |
175 | 173 |
176 bool AllProfilesContainSamePasswordFormsAsVerifier() { | 174 bool AllProfilesContainSamePasswordFormsAsVerifier() { |
177 for (int i = 0; i < test()->num_clients(); ++i) { | 175 for (int i = 0; i < test()->num_clients(); ++i) { |
178 if (!ProfileContainsSamePasswordFormsAsVerifier(i)) { | 176 if (!ProfileContainsSamePasswordFormsAsVerifier(i)) { |
179 DVLOG(1) << "Profile " << i << " does not contain the same password" | 177 DVLOG(1) << "Profile " << i << " does not contain the same password" |
180 " forms as the verifier."; | 178 " forms as the verifier."; |
181 return false; | 179 return false; |
182 } | 180 } |
183 } | 181 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 form.origin = GURL(base::StringPrintf(kIndexedFakeOrigin, index)); | 342 form.origin = GURL(base::StringPrintf(kIndexedFakeOrigin, index)); |
345 form.username_value = | 343 form.username_value = |
346 base::ASCIIToUTF16(base::StringPrintf("username%d", index)); | 344 base::ASCIIToUTF16(base::StringPrintf("username%d", index)); |
347 form.password_value = | 345 form.password_value = |
348 base::ASCIIToUTF16(base::StringPrintf("password%d", index)); | 346 base::ASCIIToUTF16(base::StringPrintf("password%d", index)); |
349 form.date_created = base::Time::Now(); | 347 form.date_created = base::Time::Now(); |
350 return form; | 348 return form; |
351 } | 349 } |
352 | 350 |
353 } // namespace passwords_helper | 351 } // namespace passwords_helper |
OLD | NEW |