| 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 540963d65761d69c9503cca2f80e33bbbf9c288d..c67ac8be778dcf5aab5a2151b5de2f9848624d2e 100644
|
| --- a/components/password_manager/core/browser/affiliation_utils_unittest.cc
|
| +++ b/components/password_manager/core/browser/affiliation_utils_unittest.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include "components/password_manager/core/browser/affiliation_utils.h"
|
|
|
| +#include "base/command_line.h"
|
| +#include "base/metrics/field_trial.h"
|
| +#include "components/password_manager/core/common/password_manager_switches.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "url/url_constants.h"
|
|
|
| @@ -192,4 +195,44 @@ TEST(AffiliationUtilsTest, NotEqualEquivalenceClasses) {
|
| EXPECT_FALSE(AreEquivalenceClassesEqual(c, b));
|
| }
|
|
|
| +TEST(AffiliationUtilsTest, IsAffiliationBasedMatchingEnabled) {
|
| + const char kFieldTrialName[] = "AffiliationBasedMatching";
|
| +
|
| + struct {
|
| + const char* field_trial_group;
|
| + const char* command_line_switch;
|
| + bool expected_enabled;
|
| + } kTestCases[] = {
|
| + {"", "", false},
|
| + {"", switches::kEnableAffiliationBasedMatching, true},
|
| + {"", switches::kDisableAffiliationBasedMatching, false},
|
| + {"garbage value", "", false},
|
| + {"disabled", "", false},
|
| + {"disabled2", "", false},
|
| + {"Disabled", "", false},
|
| + {"Disabled", switches::kDisableAffiliationBasedMatching, false},
|
| + {"Disabled", switches::kEnableAffiliationBasedMatching, true},
|
| + {"enabled", "", true},
|
| + {"enabled2", "", true},
|
| + {"Enabled", "", true},
|
| + {"Enabled", switches::kDisableAffiliationBasedMatching, false},
|
| + {"Enabled", switches::kEnableAffiliationBasedMatching, true}};
|
| +
|
| + for (const auto& test_case : kTestCases) {
|
| + SCOPED_TRACE(testing::Message("Command line = ")
|
| + << test_case.command_line_switch);
|
| + SCOPED_TRACE(testing::Message("Group name = ")
|
| + << test_case.field_trial_group);
|
| +
|
| + base::FieldTrialList field_trials(NULL);
|
| + 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));
|
| + }
|
| +}
|
| +
|
| } // namespace password_manager
|
|
|