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

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

Issue 299443002: Password Login Database: report correct changes from UpdateLogin(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added UpdateNonexistentLogin tests Created 6 years, 7 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 | Annotate | Revision Log
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/file_util.h" 8 #include "base/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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void(const password_manager::PasswordStoreChangeList& changes)); 55 void(const password_manager::PasswordStoreChangeList& changes));
56 }; 56 };
57 57
58 class FailingBackend : public PasswordStoreX::NativeBackend { 58 class FailingBackend : public PasswordStoreX::NativeBackend {
59 public: 59 public:
60 virtual bool Init() OVERRIDE { return true; } 60 virtual bool Init() OVERRIDE { return true; }
61 61
62 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE { 62 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE {
63 return PasswordStoreChangeList(); 63 return PasswordStoreChangeList();
64 } 64 }
65 virtual bool UpdateLogin(const PasswordForm& form) OVERRIDE { return false; } 65 virtual bool UpdateLogin(const PasswordForm& form,
66 PasswordStoreChangeList* changes) OVERRIDE {
67 return false;
68 }
66 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE { return false; } 69 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE { return false; }
67 70
68 virtual bool RemoveLoginsCreatedBetween( 71 virtual bool RemoveLoginsCreatedBetween(
69 const base::Time& delete_begin, 72 const base::Time& delete_begin,
70 const base::Time& delete_end) OVERRIDE { 73 const base::Time& delete_end) OVERRIDE {
71 return false; 74 return false;
72 } 75 }
73 76
74 virtual bool GetLogins(const PasswordForm& form, 77 virtual bool GetLogins(const PasswordForm& form,
75 PasswordFormList* forms) OVERRIDE { 78 PasswordFormList* forms) OVERRIDE {
(...skipping 17 matching lines...) Expand all
93 class MockBackend : public PasswordStoreX::NativeBackend { 96 class MockBackend : public PasswordStoreX::NativeBackend {
94 public: 97 public:
95 virtual bool Init() OVERRIDE { return true; } 98 virtual bool Init() OVERRIDE { return true; }
96 99
97 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE { 100 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE {
98 all_forms_.push_back(form); 101 all_forms_.push_back(form);
99 PasswordStoreChange change(PasswordStoreChange::ADD, form); 102 PasswordStoreChange change(PasswordStoreChange::ADD, form);
100 return PasswordStoreChangeList(1, change); 103 return PasswordStoreChangeList(1, change);
101 } 104 }
102 105
103 virtual bool UpdateLogin(const PasswordForm& form) OVERRIDE { 106 virtual bool UpdateLogin(const PasswordForm& form,
107 PasswordStoreChangeList* changes) OVERRIDE {
104 for (size_t i = 0; i < all_forms_.size(); ++i) 108 for (size_t i = 0; i < all_forms_.size(); ++i)
105 if (CompareForms(all_forms_[i], form, true)) 109 if (CompareForms(all_forms_[i], form, true)) {
106 all_forms_[i] = form; 110 all_forms_[i] = form;
111 changes->push_back(PasswordStoreChange(PasswordStoreChange::UPDATE,
112 form));
113 }
107 return true; 114 return true;
108 } 115 }
109 116
110 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE { 117 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE {
111 for (size_t i = 0; i < all_forms_.size(); ++i) 118 for (size_t i = 0; i < all_forms_.size(); ++i)
112 if (CompareForms(all_forms_[i], form, false)) 119 if (CompareForms(all_forms_[i], form, false))
113 erase(i--); 120 erase(i--);
114 return true; 121 return true;
115 } 122 }
116 123
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 454
448 INSTANTIATE_TEST_CASE_P(NoBackend, 455 INSTANTIATE_TEST_CASE_P(NoBackend,
449 PasswordStoreXTest, 456 PasswordStoreXTest,
450 testing::Values(NO_BACKEND)); 457 testing::Values(NO_BACKEND));
451 INSTANTIATE_TEST_CASE_P(FailingBackend, 458 INSTANTIATE_TEST_CASE_P(FailingBackend,
452 PasswordStoreXTest, 459 PasswordStoreXTest,
453 testing::Values(FAILING_BACKEND)); 460 testing::Values(FAILING_BACKEND));
454 INSTANTIATE_TEST_CASE_P(WorkingBackend, 461 INSTANTIATE_TEST_CASE_P(WorkingBackend,
455 PasswordStoreXTest, 462 PasswordStoreXTest,
456 testing::Values(WORKING_BACKEND)); 463 testing::Values(WORKING_BACKEND));
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_x.cc ('k') | components/password_manager/core/browser/login_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698