| 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" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 class TestAutofillMetrics : public autofill::AutofillMetrics { | 104 class TestAutofillMetrics : public autofill::AutofillMetrics { |
| 105 public: | 105 public: |
| 106 TestAutofillMetrics() {} | 106 TestAutofillMetrics() {} |
| 107 ~TestAutofillMetrics() override {} | 107 ~TestAutofillMetrics() override {} |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // anonymous namespace | 110 } // anonymous namespace |
| 111 | 111 |
| 112 class PasswordGenerationManagerTest : public testing::Test { | 112 class PasswordGenerationManagerTest : public testing::Test { |
| 113 protected: | 113 protected: |
| 114 virtual void SetUp() override { | 114 void SetUp() override { |
| 115 // Construct a PrefService and register all necessary prefs before handing | 115 // Construct a PrefService and register all necessary prefs before handing |
| 116 // it off to |client_|, as the initialization flow of |client_| will | 116 // it off to |client_|, as the initialization flow of |client_| will |
| 117 // indirectly cause those prefs to be immediately accessed. | 117 // indirectly cause those prefs to be immediately accessed. |
| 118 scoped_ptr<TestingPrefServiceSimple> prefs(new TestingPrefServiceSimple()); | 118 scoped_ptr<TestingPrefServiceSimple> prefs(new TestingPrefServiceSimple()); |
| 119 prefs->registry()->RegisterBooleanPref(prefs::kPasswordManagerSavingEnabled, | 119 prefs->registry()->RegisterBooleanPref(prefs::kPasswordManagerSavingEnabled, |
| 120 true); | 120 true); |
| 121 client_.reset(new TestPasswordManagerClient(prefs.Pass())); | 121 client_.reset(new TestPasswordManagerClient(prefs.Pass())); |
| 122 } | 122 } |
| 123 | 123 |
| 124 virtual void TearDown() override { client_.reset(); } | 124 void TearDown() override { client_.reset(); } |
| 125 | 125 |
| 126 PasswordGenerationManager* GetGenerationManager() { | 126 PasswordGenerationManager* GetGenerationManager() { |
| 127 return client_->GetDriver()->GetPasswordGenerationManager(); | 127 return client_->GetDriver()->GetPasswordGenerationManager(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TestPasswordManagerDriver* GetTestDriver() { | 130 TestPasswordManagerDriver* GetTestDriver() { |
| 131 return static_cast<TestPasswordManagerDriver*>(client_->GetDriver()); | 131 return static_cast<TestPasswordManagerDriver*>(client_->GetDriver()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool IsGenerationEnabled() { | 134 bool IsGenerationEnabled() { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // be disabled. | 219 // be disabled. |
| 220 GetTestDriver()->set_is_off_the_record(true); | 220 GetTestDriver()->set_is_off_the_record(true); |
| 221 PrefService* prefs = client_->GetPrefs(); | 221 PrefService* prefs = client_->GetPrefs(); |
| 222 prefs->SetBoolean(prefs::kPasswordManagerSavingEnabled, true); | 222 prefs->SetBoolean(prefs::kPasswordManagerSavingEnabled, true); |
| 223 client_->set_is_password_sync_enabled(true); | 223 client_->set_is_password_sync_enabled(true); |
| 224 | 224 |
| 225 EXPECT_FALSE(IsGenerationEnabled()); | 225 EXPECT_FALSE(IsGenerationEnabled()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace password_manager | 228 } // namespace password_manager |
| OLD | NEW |