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

Side by Side Diff: chrome/browser/password_manager/password_store_x_unittest.cc

Issue 906973007: PasswordStore: Clean up expectations about rewriting vectors of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix FillMatchingLogins + a typo Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 bool RemoveLoginsSyncedBetween( 76 bool RemoveLoginsSyncedBetween(
77 base::Time delete_begin, 77 base::Time delete_begin,
78 base::Time delete_end, 78 base::Time delete_end,
79 password_manager::PasswordStoreChangeList* changes) override { 79 password_manager::PasswordStoreChangeList* changes) override {
80 return false; 80 return false;
81 } 81 }
82 82
83 bool GetLogins(const PasswordForm& form, 83 bool GetLogins(const PasswordForm& form,
84 ScopedVector<autofill::PasswordForm>* forms) override { 84 ScopedVector<autofill::PasswordForm>* forms) override {
85 forms->clear();
85 return false; 86 return false;
86 } 87 }
87 88
88 bool GetAutofillableLogins( 89 bool GetAutofillableLogins(
89 ScopedVector<autofill::PasswordForm>* forms) override { 90 ScopedVector<autofill::PasswordForm>* forms) override {
91 forms->clear();
90 return false; 92 return false;
91 } 93 }
92 bool GetBlacklistLogins( 94 bool GetBlacklistLogins(
93 ScopedVector<autofill::PasswordForm>* forms) override { 95 ScopedVector<autofill::PasswordForm>* forms) override {
96 forms->clear();
94 return false; 97 return false;
95 } 98 }
96 }; 99 };
97 100
98 class MockBackend : public PasswordStoreX::NativeBackend { 101 class MockBackend : public PasswordStoreX::NativeBackend {
99 public: 102 public:
100 bool Init() override { return true; } 103 bool Init() override { return true; }
101 104
102 PasswordStoreChangeList AddLogin(const PasswordForm& form) override { 105 PasswordStoreChangeList AddLogin(const PasswordForm& form) override {
103 all_forms_.push_back(form); 106 all_forms_.push_back(form);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 public: 203 public:
201 MOCK_METHOD1(OnLoginDatabaseQueryDone, 204 MOCK_METHOD1(OnLoginDatabaseQueryDone,
202 void(const std::vector<PasswordForm*>&)); 205 void(const std::vector<PasswordForm*>&));
203 }; 206 };
204 207
205 void LoginDatabaseQueryCallback(password_manager::LoginDatabase* login_db, 208 void LoginDatabaseQueryCallback(password_manager::LoginDatabase* login_db,
206 bool autofillable, 209 bool autofillable,
207 MockLoginDatabaseReturn* mock_return) { 210 MockLoginDatabaseReturn* mock_return) {
208 ScopedVector<autofill::PasswordForm> forms; 211 ScopedVector<autofill::PasswordForm> forms;
209 if (autofillable) 212 if (autofillable)
210 login_db->GetAutofillableLogins(&forms); 213 EXPECT_TRUE(login_db->GetAutofillableLogins(&forms));
211 else 214 else
212 login_db->GetBlacklistLogins(&forms); 215 EXPECT_TRUE(login_db->GetBlacklistLogins(&forms));
213 mock_return->OnLoginDatabaseQueryDone(forms.get()); 216 mock_return->OnLoginDatabaseQueryDone(forms.get());
214 } 217 }
215 218
216 // Generate |count| expected logins, either auto-fillable or blacklisted. 219 // Generate |count| expected logins, either auto-fillable or blacklisted.
217 void InitExpectedForms(bool autofillable, 220 void InitExpectedForms(bool autofillable,
218 size_t count, 221 size_t count,
219 ScopedVector<autofill::PasswordForm>* forms) { 222 ScopedVector<autofill::PasswordForm>* forms) {
220 const char* domain = autofillable ? "example" : "blacklisted"; 223 const char* domain = autofillable ? "example" : "blacklisted";
221 for (size_t i = 0; i < count; ++i) { 224 for (size_t i = 0; i < count; ++i) {
222 std::string realm = base::StringPrintf("http://%zu.%s.com", i, domain); 225 std::string realm = base::StringPrintf("http://%zu.%s.com", i, domain);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 462
460 INSTANTIATE_TEST_CASE_P(NoBackend, 463 INSTANTIATE_TEST_CASE_P(NoBackend,
461 PasswordStoreXTest, 464 PasswordStoreXTest,
462 testing::Values(NO_BACKEND)); 465 testing::Values(NO_BACKEND));
463 INSTANTIATE_TEST_CASE_P(FailingBackend, 466 INSTANTIATE_TEST_CASE_P(FailingBackend,
464 PasswordStoreXTest, 467 PasswordStoreXTest,
465 testing::Values(FAILING_BACKEND)); 468 testing::Values(FAILING_BACKEND));
466 INSTANTIATE_TEST_CASE_P(WorkingBackend, 469 INSTANTIATE_TEST_CASE_P(WorkingBackend,
467 PasswordStoreXTest, 470 PasswordStoreXTest,
468 testing::Values(WORKING_BACKEND)); 471 testing::Values(WORKING_BACKEND));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698