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 "chrome/browser/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/testing_pref_service.h" | 10 #include "base/prefs/testing_pref_service.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/sync/profile_sync_service_factory.h" | 13 #include "chrome/browser/sync/profile_sync_service_factory.h" |
14 #include "chrome/browser/sync/profile_sync_service_mock.h" | 14 #include "chrome/browser/sync/profile_sync_service_mock.h" |
15 #include "chrome/common/chrome_version_info.h" | 15 #include "chrome/common/channel_info.h" |
16 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 16 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
17 #include "chrome/test/base/testing_pref_service_syncable.h" | 17 #include "chrome/test/base/testing_pref_service_syncable.h" |
18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
19 #include "components/autofill/content/common/autofill_messages.h" | 19 #include "components/autofill/content/common/autofill_messages.h" |
20 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" | 20 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" |
21 #include "components/password_manager/content/common/credential_manager_messages
.h" | 21 #include "components/password_manager/content/common/credential_manager_messages
.h" |
22 #include "components/password_manager/core/browser/log_receiver.h" | 22 #include "components/password_manager/core/browser/log_receiver.h" |
23 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" | 23 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" |
24 #include "components/password_manager/core/common/credential_manager_types.h" | 24 #include "components/password_manager/core/common/credential_manager_types.h" |
25 #include "components/password_manager/core/common/password_manager_pref_names.h" | 25 #include "components/password_manager/core/common/password_manager_pref_names.h" |
26 #include "components/password_manager/core/common/password_manager_switches.h" | 26 #include "components/password_manager/core/common/password_manager_switches.h" |
| 27 #include "components/version_info/version_info.h" |
27 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
29 #include "content/public/test/mock_render_process_host.h" | 30 #include "content/public/test/mock_render_process_host.h" |
30 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
32 | 33 |
33 using content::BrowserContext; | 34 using content::BrowserContext; |
34 using content::WebContents; | 35 using content::WebContents; |
35 using testing::Return; | 36 using testing::Return; |
36 using testing::_; | 37 using testing::_; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 213 |
213 TEST_F(ChromePasswordManagerClientTest, | 214 TEST_F(ChromePasswordManagerClientTest, |
214 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) { | 215 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) { |
215 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); | 216 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); |
216 } | 217 } |
217 | 218 |
218 TEST_F(ChromePasswordManagerClientTest, | 219 TEST_F(ChromePasswordManagerClientTest, |
219 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) { | 220 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) { |
220 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 221 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
221 password_manager::switches::kEnableAutomaticPasswordSaving); | 222 password_manager::switches::kEnableAutomaticPasswordSaving); |
222 if (chrome::VersionInfo::GetChannel() == version_info::Channel::UNKNOWN) | 223 if (chrome::GetChannel() == version_info::Channel::UNKNOWN) |
223 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled()); | 224 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled()); |
224 else | 225 else |
225 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); | 226 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); |
226 } | 227 } |
227 | 228 |
228 TEST_F(ChromePasswordManagerClientTest, LogToAReceiver) { | 229 TEST_F(ChromePasswordManagerClientTest, LogToAReceiver) { |
229 ChromePasswordManagerClient* client = GetClient(); | 230 ChromePasswordManagerClient* client = GetClient(); |
230 service_->RegisterReceiver(&receiver_); | 231 service_->RegisterReceiver(&receiver_); |
231 EXPECT_TRUE(client->IsLoggingActive()); | 232 EXPECT_TRUE(client->IsLoggingActive()); |
232 | 233 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 profile()->ForceIncognito(true); | 461 profile()->ForceIncognito(true); |
461 EXPECT_FALSE(client->IsSavingEnabledForCurrentPage()); | 462 EXPECT_FALSE(client->IsSavingEnabledForCurrentPage()); |
462 | 463 |
463 // Functionality disabled in Incognito mode also when manager itself is | 464 // Functionality disabled in Incognito mode also when manager itself is |
464 // enabled. | 465 // enabled. |
465 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, | 466 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, |
466 new base::FundamentalValue(true)); | 467 new base::FundamentalValue(true)); |
467 EXPECT_FALSE(client->IsSavingEnabledForCurrentPage()); | 468 EXPECT_FALSE(client->IsSavingEnabledForCurrentPage()); |
468 profile()->ForceIncognito(false); | 469 profile()->ForceIncognito(false); |
469 } | 470 } |
OLD | NEW |