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

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

Issue 283563002: Password Login Database: report correct changes from AddLogin(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unused variable 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/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 12 matching lines...) Expand all
23 #include "components/password_manager/core/common/password_manager_pref_names.h" 23 #include "components/password_manager/core/common/password_manager_pref_names.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 28
29 using autofill::PasswordForm; 29 using autofill::PasswordForm;
30 using content::BrowserThread; 30 using content::BrowserThread;
31 using password_manager::ContainsAllPasswordForms; 31 using password_manager::ContainsAllPasswordForms;
32 using password_manager::PasswordStoreChange; 32 using password_manager::PasswordStoreChange;
33 using password_manager::PasswordStoreChangeList;
33 using testing::_; 34 using testing::_;
34 using testing::DoAll; 35 using testing::DoAll;
35 using testing::ElementsAreArray; 36 using testing::ElementsAreArray;
36 using testing::Pointee; 37 using testing::Pointee;
37 using testing::Property; 38 using testing::Property;
38 using testing::WithArg; 39 using testing::WithArg;
39 40
40 typedef std::vector<PasswordForm*> VectorOfForms; 41 typedef std::vector<PasswordForm*> VectorOfForms;
41 42
42 namespace { 43 namespace {
43 44
44 class MockPasswordStoreConsumer 45 class MockPasswordStoreConsumer
45 : public password_manager::PasswordStoreConsumer { 46 : public password_manager::PasswordStoreConsumer {
46 public: 47 public:
47 MOCK_METHOD1(OnGetPasswordStoreResults, 48 MOCK_METHOD1(OnGetPasswordStoreResults,
48 void(const std::vector<PasswordForm*>&)); 49 void(const std::vector<PasswordForm*>&));
49 }; 50 };
50 51
51 class MockPasswordStoreObserver 52 class MockPasswordStoreObserver
52 : public password_manager::PasswordStore::Observer { 53 : public password_manager::PasswordStore::Observer {
53 public: 54 public:
54 MOCK_METHOD1(OnLoginsChanged, 55 MOCK_METHOD1(OnLoginsChanged,
55 void(const password_manager::PasswordStoreChangeList& changes)); 56 void(const password_manager::PasswordStoreChangeList& changes));
56 }; 57 };
57 58
58 class FailingBackend : public PasswordStoreX::NativeBackend { 59 class FailingBackend : public PasswordStoreX::NativeBackend {
59 public: 60 public:
60 virtual bool Init() OVERRIDE { return true; } 61 virtual bool Init() OVERRIDE { return true; }
61 62
62 virtual bool AddLogin(const PasswordForm& form) OVERRIDE { return false; } 63 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE {
64 return PasswordStoreChangeList();
65 }
63 virtual bool UpdateLogin(const PasswordForm& form) OVERRIDE { return false; } 66 virtual bool UpdateLogin(const PasswordForm& form) OVERRIDE { return false; }
64 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE { return false; } 67 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE { return false; }
65 68
66 virtual bool RemoveLoginsCreatedBetween( 69 virtual bool RemoveLoginsCreatedBetween(
67 const base::Time& delete_begin, 70 const base::Time& delete_begin,
68 const base::Time& delete_end) OVERRIDE { 71 const base::Time& delete_end) OVERRIDE {
69 return false; 72 return false;
70 } 73 }
71 74
72 virtual bool GetLogins(const PasswordForm& form, 75 virtual bool GetLogins(const PasswordForm& form,
(...skipping 12 matching lines...) Expand all
85 } 88 }
86 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE { 89 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE {
87 return false; 90 return false;
88 } 91 }
89 }; 92 };
90 93
91 class MockBackend : public PasswordStoreX::NativeBackend { 94 class MockBackend : public PasswordStoreX::NativeBackend {
92 public: 95 public:
93 virtual bool Init() OVERRIDE { return true; } 96 virtual bool Init() OVERRIDE { return true; }
94 97
95 virtual bool AddLogin(const PasswordForm& form) OVERRIDE { 98 virtual PasswordStoreChangeList AddLogin(const PasswordForm& form) OVERRIDE {
96 all_forms_.push_back(form); 99 all_forms_.push_back(form);
97 return true; 100 PasswordStoreChange change(PasswordStoreChange::ADD, form);
101 return PasswordStoreChangeList(1, change);
98 } 102 }
99 103
100 virtual bool UpdateLogin(const PasswordForm& form) OVERRIDE { 104 virtual bool UpdateLogin(const PasswordForm& form) OVERRIDE {
101 for (size_t i = 0; i < all_forms_.size(); ++i) 105 for (size_t i = 0; i < all_forms_.size(); ++i)
102 if (CompareForms(all_forms_[i], form, true)) 106 if (CompareForms(all_forms_[i], form, true))
103 all_forms_[i] = form; 107 all_forms_[i] = form;
104 return true; 108 return true;
105 } 109 }
106 110
107 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE { 111 virtual bool RemoveLogin(const PasswordForm& form) OVERRIDE {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 448
445 INSTANTIATE_TEST_CASE_P(NoBackend, 449 INSTANTIATE_TEST_CASE_P(NoBackend,
446 PasswordStoreXTest, 450 PasswordStoreXTest,
447 testing::Values(NO_BACKEND)); 451 testing::Values(NO_BACKEND));
448 INSTANTIATE_TEST_CASE_P(FailingBackend, 452 INSTANTIATE_TEST_CASE_P(FailingBackend,
449 PasswordStoreXTest, 453 PasswordStoreXTest,
450 testing::Values(FAILING_BACKEND)); 454 testing::Values(FAILING_BACKEND));
451 INSTANTIATE_TEST_CASE_P(WorkingBackend, 455 INSTANTIATE_TEST_CASE_P(WorkingBackend,
452 PasswordStoreXTest, 456 PasswordStoreXTest,
453 testing::Values(WORKING_BACKEND)); 457 testing::Values(WORKING_BACKEND));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698