OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "components/autofill/core/browser/autofill_field.h" | 11 #include "components/autofill/core/browser/autofill_field.h" |
12 #include "components/autofill/core/browser/autofill_metrics.h" | 12 #include "components/autofill/core/browser/autofill_metrics.h" |
13 #include "components/autofill/core/browser/form_structure.h" | 13 #include "components/autofill/core/browser/form_structure.h" |
14 #include "components/autofill/core/common/form_data.h" | 14 #include "components/autofill/core/common/form_data.h" |
15 #include "components/autofill/core/common/form_field_data.h" | 15 #include "components/autofill/core/common/form_field_data.h" |
16 #include "components/password_manager/core/browser/password_autofill_manager.h" | 16 #include "components/password_manager/core/browser/password_autofill_manager.h" |
17 #include "components/password_manager/core/browser/password_generation_manager.h " | 17 #include "components/password_manager/core/browser/password_generation_manager.h " |
18 #include "components/password_manager/core/browser/password_manager.h" | 18 #include "components/password_manager/core/browser/password_manager.h" |
19 #include "components/password_manager/core/browser/stub_password_manager_client. h" | 19 #include "components/password_manager/core/browser/stub_password_manager_client. h" |
20 #include "components/password_manager/core/browser/stub_password_manager_driver. h" | 20 #include "components/password_manager/core/browser/stub_password_manager_driver. h" |
21 #include "components/password_manager/core/browser/test_password_store.h" | |
21 #include "components/password_manager/core/common/password_manager_pref_names.h" | 22 #include "components/password_manager/core/common/password_manager_pref_names.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 | 25 |
25 using base::ASCIIToUTF16; | 26 using base::ASCIIToUTF16; |
26 | 27 |
27 namespace password_manager { | 28 namespace password_manager { |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 PasswordManager password_manager_; | 64 PasswordManager password_manager_; |
64 PasswordGenerationManager password_generation_manager_; | 65 PasswordGenerationManager password_generation_manager_; |
65 PasswordAutofillManager password_autofill_manager_; | 66 PasswordAutofillManager password_autofill_manager_; |
66 std::vector<autofill::FormData> found_account_creation_forms_; | 67 std::vector<autofill::FormData> found_account_creation_forms_; |
67 bool is_off_the_record_; | 68 bool is_off_the_record_; |
68 }; | 69 }; |
69 | 70 |
70 class TestPasswordManagerClient : public StubPasswordManagerClient { | 71 class TestPasswordManagerClient : public StubPasswordManagerClient { |
71 public: | 72 public: |
72 TestPasswordManagerClient(scoped_ptr<PrefService> prefs) | 73 TestPasswordManagerClient(scoped_ptr<PrefService> prefs) |
73 : prefs_(prefs.Pass()), driver_(this), is_sync_enabled_(false) {} | 74 : prefs_(prefs.Pass()), |
75 store_(new TestPasswordStore), | |
76 driver_(this), | |
77 is_sync_enabled_(false) {} | |
74 | 78 |
75 PasswordStore* GetPasswordStore() override { return NULL; } | 79 ~TestPasswordManagerClient() { |
vabr (Chromium)
2014/10/24 06:30:28
Should this also be 'override'?
Garrett Casto
2014/10/24 18:25:03
Good catch. Done.
| |
80 store_->Shutdown(); | |
81 } | |
82 | |
83 PasswordStore* GetPasswordStore() override { return store_.get(); } | |
76 PrefService* GetPrefs() override { return prefs_.get(); } | 84 PrefService* GetPrefs() override { return prefs_.get(); } |
77 PasswordManagerDriver* GetDriver() override { return &driver_; } | 85 PasswordManagerDriver* GetDriver() override { return &driver_; } |
78 bool IsPasswordSyncEnabled() override { return is_sync_enabled_; } | 86 bool IsPasswordSyncEnabled(CustomPassphraseState state) override { |
87 return is_sync_enabled_; | |
88 } | |
79 | 89 |
80 void set_is_password_sync_enabled(bool enabled) { | 90 void set_is_password_sync_enabled(bool enabled) { |
81 is_sync_enabled_ = enabled; | 91 is_sync_enabled_ = enabled; |
82 } | 92 } |
83 | 93 |
84 private: | 94 private: |
85 scoped_ptr<PrefService> prefs_; | 95 scoped_ptr<PrefService> prefs_; |
96 scoped_refptr<TestPasswordStore> store_; | |
86 TestPasswordManagerDriver driver_; | 97 TestPasswordManagerDriver driver_; |
87 bool is_sync_enabled_; | 98 bool is_sync_enabled_; |
88 }; | 99 }; |
89 | 100 |
90 // Unlike the base AutofillMetrics, exposes copy and assignment constructors, | 101 // Unlike the base AutofillMetrics, exposes copy and assignment constructors, |
91 // which are handy for briefer test code. The AutofillMetrics class is | 102 // which are handy for briefer test code. The AutofillMetrics class is |
92 // stateless, so this is safe. | 103 // stateless, so this is safe. |
93 class TestAutofillMetrics : public autofill::AutofillMetrics { | 104 class TestAutofillMetrics : public autofill::AutofillMetrics { |
94 public: | 105 public: |
95 TestAutofillMetrics() {} | 106 TestAutofillMetrics() {} |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 // be disabled. | 219 // be disabled. |
209 GetTestDriver()->set_is_off_the_record(true); | 220 GetTestDriver()->set_is_off_the_record(true); |
210 PrefService* prefs = client_->GetPrefs(); | 221 PrefService* prefs = client_->GetPrefs(); |
211 prefs->SetBoolean(prefs::kPasswordManagerSavingEnabled, true); | 222 prefs->SetBoolean(prefs::kPasswordManagerSavingEnabled, true); |
212 client_->set_is_password_sync_enabled(true); | 223 client_->set_is_password_sync_enabled(true); |
213 | 224 |
214 EXPECT_FALSE(IsGenerationEnabled()); | 225 EXPECT_FALSE(IsGenerationEnabled()); |
215 } | 226 } |
216 | 227 |
217 } // namespace password_manager | 228 } // namespace password_manager |
OLD | NEW |