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

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

Issue 2226063002: Add a ScopedFeatureList class for testing and start using it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issue in previous patchset. Created 4 years, 4 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
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <tuple> 10 #include <tuple>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/test/scoped_feature_list.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h" 17 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "chrome/browser/sync/profile_sync_test_util.h" 18 #include "chrome/browser/sync/profile_sync_test_util.h"
18 #include "chrome/common/channel_info.h" 19 #include "chrome/common/channel_info.h"
19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 20 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
20 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
21 #include "components/autofill/content/common/autofill_messages.h" 22 #include "components/autofill/content/common/autofill_messages.h"
22 #include "components/password_manager/content/browser/password_manager_internals _service_factory.h" 23 #include "components/password_manager/content/browser/password_manager_internals _service_factory.h"
23 #include "components/password_manager/core/browser/credentials_filter.h" 24 #include "components/password_manager/core/browser/credentials_filter.h"
24 #include "components/password_manager/core/browser/log_manager.h" 25 #include "components/password_manager/core/browser/log_manager.h"
25 #include "components/password_manager/core/browser/log_receiver.h" 26 #include "components/password_manager/core/browser/log_receiver.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 161 }
161 162
162 TEST_F(ChromePasswordManagerClientTest, 163 TEST_F(ChromePasswordManagerClientTest,
163 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) { 164 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) {
164 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); 165 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled());
165 } 166 }
166 167
167 TEST_F(ChromePasswordManagerClientTest, 168 TEST_F(ChromePasswordManagerClientTest,
168 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) { 169 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) {
169 // Add the enable-automatic-password-saving feature. 170 // Add the enable-automatic-password-saving feature.
170 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 171 base::test::ScopedFeatureList scoped_feature_list;
171 std::vector<const base::Feature*> enabled_features; 172 scoped_feature_list.InitAndEnableFeature(
172 std::vector<const base::Feature*> disabled_features; 173 password_manager::features::kEnableAutomaticPasswordSaving);
173 enabled_features.push_back(
174 &password_manager::features::kEnableAutomaticPasswordSaving);
175 password_manager::SetFeatures(enabled_features, disabled_features,
176 std::move(feature_list));
177 174
178 if (chrome::GetChannel() == version_info::Channel::UNKNOWN) 175 if (chrome::GetChannel() == version_info::Channel::UNKNOWN)
179 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled()); 176 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled());
180 else 177 else
181 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); 178 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled());
182 } 179 }
183 180
184 TEST_F(ChromePasswordManagerClientTest, GetPasswordSyncState) { 181 TEST_F(ChromePasswordManagerClientTest, GetPasswordSyncState) {
185 ChromePasswordManagerClient* client = GetClient(); 182 ChromePasswordManagerClient* client = GetClient();
186 183
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 PasswordManagerInternalsServiceFactory::GetForBrowserContext(profile()); 345 PasswordManagerInternalsServiceFactory::GetForBrowserContext(profile());
349 DummyLogReceiver log_receiver; 346 DummyLogReceiver log_receiver;
350 EXPECT_EQ(std::string(), log_router->RegisterReceiver(&log_receiver)); 347 EXPECT_EQ(std::string(), log_router->RegisterReceiver(&log_receiver));
351 348
352 // But then navigate to a WebUI, there the logging should not be active. 349 // But then navigate to a WebUI, there the logging should not be active.
353 NavigateAndCommit(GURL("about:password-manager-internals")); 350 NavigateAndCommit(GURL("about:password-manager-internals"));
354 EXPECT_FALSE(GetClient()->GetLogManager()->IsLoggingActive()); 351 EXPECT_FALSE(GetClient()->GetLogManager()->IsLoggingActive());
355 352
356 log_router->UnregisterReceiver(&log_receiver); 353 log_router->UnregisterReceiver(&log_receiver);
357 } 354 }
OLDNEW
« no previous file with comments | « base/test/scoped_feature_list.cc ('k') | components/autofill/core/browser/autofill_assistant_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698