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

Unified Diff: components/password_manager/core/browser/affiliation_utils_unittest.cc

Issue 898553002: Add flag to enable/disable affiliaton based matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work on terminology. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698