Index: components/password_manager/core/browser/affiliation_utils_unittest.cc |
diff --git a/components/password_manager/core/browser/affiliation_utils_unittest.cc b/components/password_manager/core/browser/affiliation_utils_unittest.cc |
index f8f32ec4f667c5fdb0974bbf5520962b7ea58cdd..877ba79b57688f2b9e224422f682fac9bbc3c828 100644 |
--- a/components/password_manager/core/browser/affiliation_utils_unittest.cc |
+++ b/components/password_manager/core/browser/affiliation_utils_unittest.cc |
@@ -4,11 +4,10 @@ |
#include "components/password_manager/core/browser/affiliation_utils.h" |
-#include "base/command_line.h" |
#include "base/metrics/field_trial.h" |
#include "base/strings/utf_string_conversions.h" |
#include "components/autofill/core/common/password_form.h" |
-#include "components/password_manager/core/common/password_manager_switches.h" |
+#include "components/password_manager/core/common/password_manager_features.h" |
#include "components/variations/variations_associated_data.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "url/url_constants.h" |
@@ -21,6 +20,14 @@ const std::string kSchemeHostExample = "http://example.com"; |
const char kTestFacetURI1[] = "https://alpha.example.com/"; |
const char kTestFacetURI2[] = "https://beta.example.com/"; |
const char kTestFacetURI3[] = "https://gamma.example.com/"; |
+ |
+void EnableFeature(const char* feature) { |
+ base::FeatureList::ClearInstanceForTesting(); |
+ scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); |
+ feature_list->InitializeFromCommandLine(feature, ""); |
+ base::FeatureList::SetInstance(std::move(feature_list)); |
+} |
+ |
} // namespace |
TEST(AffiliationUtilsTest, ValidWebFacetURIs) { |
@@ -203,27 +210,27 @@ TEST(AffiliationUtilsTest, NotEqualEquivalenceClasses) { |
TEST(AffiliationUtilsTest, IsAffiliationBasedMatchingEnabled) { |
struct { |
const char* field_trial_group; |
- const char* command_line_switch; |
+ const char* command_line_feature; |
bool expected_enabled; |
} kTestCases[] = { |
{"", "", true}, |
- {"", switches::kEnableAffiliationBasedMatching, true}, |
- {"", switches::kDisableAffiliationBasedMatching, false}, |
+ {"", features::kEnableAffiliationBasedMatching.name, true}, |
+ {"", features::kDisableAffiliationBasedMatching.name, false}, |
{"garbage value", "", true}, |
{"disabled", "", false}, |
{"disabled2", "", false}, |
{"Disabled", "", false}, |
- {"Disabled", switches::kDisableAffiliationBasedMatching, false}, |
- {"Disabled", switches::kEnableAffiliationBasedMatching, true}, |
+ {"Disabled", features::kDisableAffiliationBasedMatching.name, false}, |
+ {"Disabled", features::kEnableAffiliationBasedMatching.name, true}, |
{"enabled", "", true}, |
{"enabled2", "", true}, |
{"Enabled", "", true}, |
- {"Enabled", switches::kDisableAffiliationBasedMatching, false}, |
- {"Enabled", switches::kEnableAffiliationBasedMatching, true}}; |
+ {"Enabled", features::kDisableAffiliationBasedMatching.name, false}, |
+ {"Enabled", features::kEnableAffiliationBasedMatching.name, true}}; |
for (const auto& test_case : kTestCases) { |
SCOPED_TRACE(testing::Message("Command line = ") |
- << test_case.command_line_switch); |
+ << test_case.command_line_feature); |
SCOPED_TRACE(testing::Message("Group name = ") |
<< test_case.field_trial_group); |
@@ -231,10 +238,9 @@ TEST(AffiliationUtilsTest, IsAffiliationBasedMatchingEnabled) { |
base::FieldTrialList::CreateFieldTrial(kFieldTrialName, |
test_case.field_trial_group); |
- base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
- command_line.AppendSwitch(test_case.command_line_switch); |
- EXPECT_EQ(test_case.expected_enabled, |
- IsAffiliationBasedMatchingEnabled(command_line)); |
+ // Enable the command-line feature. |
+ EnableFeature(test_case.command_line_feature); |
+ EXPECT_EQ(test_case.expected_enabled, IsAffiliationBasedMatchingEnabled()); |
} |
} |
@@ -244,25 +250,25 @@ TEST(AffiliationUtilsTest, |
struct { |
const char* variation_param; |
- const char* command_line_switch; |
+ const char* command_line_feature; |
bool expected_enabled; |
} kTestCases[] = { |
{"", "", true}, |
- {"", switches::kEnableAffiliationBasedMatching, true}, |
- {"", switches::kDisableAffiliationBasedMatching, false}, |
+ {"", features::kEnableAffiliationBasedMatching.name, true}, |
+ {"", features::kDisableAffiliationBasedMatching.name, false}, |
{"garbage value", "", true}, |
{"disabled", "", false}, |
{"Disabled", "", false}, |
- {"Disabled", switches::kDisableAffiliationBasedMatching, false}, |
- {"Disabled", switches::kEnableAffiliationBasedMatching, true}, |
+ {"Disabled", features::kDisableAffiliationBasedMatching.name, false}, |
+ {"Disabled", features::kEnableAffiliationBasedMatching.name, true}, |
{"enabled", "", true}, |
{"Enabled", "", true}, |
- {"Enabled", switches::kDisableAffiliationBasedMatching, false}, |
- {"Enabled", switches::kEnableAffiliationBasedMatching, true}}; |
+ {"Enabled", features::kDisableAffiliationBasedMatching.name, false}, |
+ {"Enabled", features::kEnableAffiliationBasedMatching.name, true}}; |
for (const auto& test_case : kTestCases) { |
SCOPED_TRACE(testing::Message("Command line = ") |
- << test_case.command_line_switch); |
+ << test_case.command_line_feature); |
SCOPED_TRACE(testing::Message("Variation param = ") |
<< test_case.variation_param); |
@@ -275,11 +281,10 @@ TEST(AffiliationUtilsTest, |
ASSERT_TRUE(variations::AssociateVariationParams( |
kFieldTrialName, kExperimentName, variation_params)); |
- base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
- command_line.AppendSwitch(test_case.command_line_switch); |
- EXPECT_EQ( |
- test_case.expected_enabled, |
- IsPropagatingPasswordChangesToWebCredentialsEnabled(command_line)); |
+ // Enable the command-line feature. |
+ EnableFeature(test_case.command_line_feature); |
+ EXPECT_EQ(test_case.expected_enabled, |
+ IsPropagatingPasswordChangesToWebCredentialsEnabled()); |
} |
} |